I have GridView that is filled with LINQ to SQL source. Here is the code
protected void FillGridView()
{
DataClassesDataContext dContext = new DataClassesDataContext();
Guid userId=(Guid)Membership.GetUser().ProviderUserKey;
var Query = from p in dContext.users
where p.userId==userId
select new {...}//here are all the columns that are selected
gvPregledi.DataSource = Query;
gvPregledi.DataBind();
}
protected void gvPregledi_RowEditing(object sender, GridViewEditEventArgs e)
{
gvPregledi.EditIndex = e.NewEditIndex;
DataBind();
}
protected void gvPregledi_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox tbBusy = (TextBox)gvPregledi.Rows[e.RowIndex].Cells[5].Controls[0];
TextBox tbuserName = (TextBox)gvPregledi.Rows[e.RowIndex].Cells[7].Controls[0];
TextBox tbuserSurname = (TextBox)gvPregledi.Rows[e.RowIndex].Cells[8].Controls[0];
TextBox tbNote = (TextBox)gvPregledi.Rows[e.RowIndex].Cells[9].Controls[0];
Guid recordId=new Guid(gvPregledi.Rows[e.RowIndex].Cells[0].Text);
var Query = from p in dContext.users
where p.recordId ==recordId
select p;
foreach (user p in Query)
{
p.Busy = tbBusy.Text;
p.Note = tbNote.Text;
p.userName = tbuserName.Text;
p.userSurname = tbuserSurname.Text;
try
{
dContext.SubmitChanges();
}
catch (Exception error)
{
//does not throw any exception
}
finally
{
}
}
This code does not throw any exception however does not update gridview neighter the database.Could someone help me?