0
protected void btn_Submit_Click(object sender, EventArgs e)
{
lbl_EmpCode.Text = "";
SPSite newsites = SPContext.Current.Site;
SPWeb webs = newsites.OpenWeb();
SPQuery query = new SPQuery();
query.Query = string.Format ("<Query>" +"<Where>"+ "<Eq>"+ "<FieldRef Name='Company_x0020_Code' />"+" <Value Type='Text'>"+ txt_Companycode.Text +"</Value>"+" </Eq>"+" </Where>"+" </Query>");
SPList list = webs.Lists["Companies"];
SPListItemCollection items = list.GetItems(query);
if (items.Count > 0)
{
txt_Companycode.Text = "";
Response.Redirect("Pages/ClaimAccount.aspx");
}
else
{
lbl_EmpCode.Text = "Company Code is not Matching with the Exisiting Record..!";
txt_Companycode.Text = "";
Response.Redirect("Pages/CompanyCodeCheck.aspx");
}
}
我的代碼出了什麼問題?在此代碼中,我通過TextBox
作爲公司代碼從用戶那裏獲取數據,然後我將其與Sharepoint列表進行比較。如果匹配,則轉到下一頁,如果不匹配,則保留在同一頁面上並提供錯誤。從字符串(query.Query)在Sharepoint 2007中部署Web控件
query.Query =「 <值類型= '文本'>構建CAML txt_Companycode.Text 「;我也嘗試過,但結果相同。 –
NaveedAnjum
2011-05-20 16:20:27
try this query.Query =「」+ txt_Companycode.Text「+」 「 –
2011-05-22 08:24:19