SPWeb currentWeb = SPContext.Current.Web;
SPList lstLogin = currentWeb.Lists["Login"];
SPQuery sQuery = new SPQuery();
sQuery.Query = "<Where><Eq><FieldRef Name='UserName' /><Value
Type='Text'>"+txtUserName.Text.ToString().ToLower()+"</Value></Eq></Where>";
SPListItemCollection myColl = lstLogin.GetItems(sQuery);
if (myColl.Count > 0)
{
lblMessage.Text = "UserName Already Exists";
}
else
{
SPListItemCollection myColl1 = lstLogin.Items;
SPListItem item = myColl1.Add();
item["UserName"] = txtUserName.Text;
item["PassWord"] = txtPassWord.Text;
item.Update();
No comments:
Post a Comment