Gagan Sikri

Gagan Sikri

  • NA
  • 1.6k
  • 222k

Linq Update Query

Nov 17 2014 2:34 PM
I am using this code to update table record using linq. Please tell me what to do as code is executing but no changes are being made to database. Code is as follows:
 
 
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
bool temp = false; ;
nsmainDataContext stc = new nsmainDataContext();
nodeinfo tbl = stc.nodeinfos.Where(m => m.nodeid == Convert.ToInt32(DropDownList1.SelectedValue)).SingleOrDefault();
if(RadioButtonList1.SelectedItem==null)
{
Label3.Visible = true;
Label3.Text = "Please select a valid choice";
}
else
{
if(RadioButtonList1.SelectedIndex==1)
{
temp = true;
tbl.nodetstatus = temp;
}
else
if(RadioButtonList1.SelectedIndex==2)
{
temp = false;
tbl.nodetstatus = temp;
}
tbl.statuschangelog = System.DateTime.Now.ToString();
//stc.SubmitChanges();
Label3.Visible = true;
Label3.Text = "Status of node " + DropDownList1.SelectedValue + " successfully changed";
}
}
 

Answers (4)