Updating DataGrid while editing, doesn't update

J

Jeff Petter

I can't seem to get the update piece working properly while doing in-place editing. I don't receive any errors, but the update doesn't take place. From the examples I've used as "go bys" it looks pretty straight forward. I've included my update code below. If anyone has any insight into my problem, I would certainly appreciate it.

Thanks,
Jeff
private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//load the dataset with the xml file
ds = new DataSet();

//load string with full path to xml file
string strFile = Server.MapPath(Request.ApplicationPath) + "\\exceptions.xml";
//load the dataset with the xml file
ds.ReadXml (strFile, XmlReadMode.InferSchema);

string strDate = ((TextBox)(e.Item.Cells[2].Controls[0])).Text;
string strException = ((TextBox)(e.Item.Cells[3].Controls[0])).Text;
string strDuration = ((TextBox)(e.Item.Cells[4].Controls[0])).Text;

//get current row
DataRow dr = ds.Tables["exceptions"].Rows[e.Item.ItemIndex];
dr["eDate"] = strDate;
dr["exception"] = strException;
dr["duration"] = strDuration;
ds.Tables["exceptions"].AcceptChanges();
ds.WriteXml (Server.MapPath(Request.ApplicationPath) + "\\exceptions.xml");
DataGrid1.EditItemIndex = -1;
BindDataGrid();
}
 
A

Avneesh Kumar

Hi Jeff!!

Check whether u r calling BindDataGrid() in onLoad event
also..Check postback conditions for the same!!

Hope it works..

Avneesh
-----Original Message-----
I can't seem to get the update piece working properly
while doing in-place editing. I don't receive any errors,
but the update doesn't take place. From the examples I've
used as "go bys" it looks pretty straight forward. I've
included my update code below. If anyone has any insight
into my problem, I would certainly appreciate it.
Thanks,
Jeff
private void DataGrid1_UpdateCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//load the dataset with the xml file
ds = new DataSet();

//load string with full path to xml file
string strFile = Server.MapPath(Request.ApplicationPath) + "\\exceptions.xml";
//load the dataset with the xml file
ds.ReadXml (strFile, XmlReadMode.InferSchema);

string strDate = ((TextBox)(e.Item.Cells[2].Controls [0])).Text;
string strException = ((TextBox)(e.Item.Cells[3].Controls [0])).Text;
string strDuration = ((TextBox)(e.Item.Cells[4].Controls [0])).Text;

//get current row
DataRow dr = ds.Tables["exceptions"].Rows [e.Item.ItemIndex];
dr["eDate"] = strDate;
dr["exception"] = strException;
dr["duration"] = strDuration;
ds.Tables["exceptions"].AcceptChanges();
ds.WriteXml (Server.MapPath(Request.ApplicationPath) + "\\exceptions.xml");
DataGrid1.EditItemIndex = -1;
BindDataGrid();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top