OK, I've been searching for an answer to a similar problem. I am using
VB 6.0 though, so I have no idea if the solution I used, will apply/ be
helpful to you at all. I will just throw it out there in case it helps
someone...
I think the DataGrid has a property called 'DataChanged'.
If you set the property to True, then all of the update / validating
stuff should happen.
I had a problem with when I changed values in my datagrid, it didn't
propogate through to the underlying recordset unless I moved to another
record (which in effect, checks the record you were previously on, and
if changes were made, then sets the DataChanged property to true and
does whatever validating is necessary).
Basically I just made a button, that when clicked, sets
DataGrid.DataChanged = True ... and BAM... my underlying recordset was
updated.
Hope it helps someone... :)
rcoco wrote:
hi,
I've tried to update my database using my datagrid but there is no
change. here is the code I'm using:
private void Update_dataGrid(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
System.Web.UI.WebControls.TextBox cstaff=new
System.Web.UI.WebControls.TextBox();
cstaff=(System.Web.UI.WebControls.TextBox)e.Item.C ells[1].Controls[0];
SqlCommand myCommand=new SqlCommand("update isp_email.staff set
stafflevel=@stafflevel where id=id",con);
myCommand.Parameters.Add(new
SqlParameter("@stafflevel",SqlDbType.VarChar,45));
myCommand.Parameters["@stafflevel"].Value=cstaff.Text;
con.Open();
myCommand.ExecuteNonQuery();
con.Close();
dgupdate.EditItemIndex=-1;
BindData();
}
ould some one help me?