J
Jeff
I'm having a problem updating a DataGrid when using the
grid's in-place editing features. I believe that my major
problem is locating the row in the dataset that matches
the row in the grid. Does anyone have any ideas how I
might do this, or where I can look to for a good resource,
as I haven't found anything on MSDN or some of my other
favorites that address this. The latest code that I've
tried is listed below.
Thanks,
Jeff
private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string strDate = ((TextBox)(e.Item.Cells
[3].Controls[0])).Text;
string strException = ((TextBox)(e.Item.Cells
[4].Controls[0])).Text;
string strDuration = ((TextBox)(e.Item.Cells
[5].Controls[0])).Text;
string strCount = ((TextBox)(e.Item.Cells
[0].Controls[0])).Text;
foreach (DataGridItem di in DataGrid1.Items)
{
if ( di.ItemIndex.ToString() == strCount)
{
//get current row
DataRow dr = ds.Tables
["exceptions"].Rows.Find (DataGrid1.DataKeys
[di.ItemIndex]);
dr["eDate"] = strDate;
dr["exception"] = strException;
dr["duration"] = strDuration;
ds.WriteXml (Server.MapPath
(Request.ApplicationPath) + "\\exceptions.xml");
DataGrid1.DataBind();
}
}
}
grid's in-place editing features. I believe that my major
problem is locating the row in the dataset that matches
the row in the grid. Does anyone have any ideas how I
might do this, or where I can look to for a good resource,
as I haven't found anything on MSDN or some of my other
favorites that address this. The latest code that I've
tried is listed below.
Thanks,
Jeff
private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string strDate = ((TextBox)(e.Item.Cells
[3].Controls[0])).Text;
string strException = ((TextBox)(e.Item.Cells
[4].Controls[0])).Text;
string strDuration = ((TextBox)(e.Item.Cells
[5].Controls[0])).Text;
string strCount = ((TextBox)(e.Item.Cells
[0].Controls[0])).Text;
foreach (DataGridItem di in DataGrid1.Items)
{
if ( di.ItemIndex.ToString() == strCount)
{
//get current row
DataRow dr = ds.Tables
["exceptions"].Rows.Find (DataGrid1.DataKeys
[di.ItemIndex]);
dr["eDate"] = strDate;
dr["exception"] = strException;
dr["duration"] = strDuration;
ds.WriteXml (Server.MapPath
(Request.ApplicationPath) + "\\exceptions.xml");
DataGrid1.DataBind();
}
}
}