Hey guys n gals
Got a bit of a situation here. I am reading an xml file into a dataset and throwing it into a datagrid for view/editing. Everything seems to work just fine except when I go to update a record. The edit button puts the grid into it's edit mode. I change some of the data and press update. Now I am successfully able to take the data in the textboxes and update the dataset with it (heres the problem) But the textboxes don't contain any of my updated data. If the text box originally had "Mark" in it and I changed it to "marc" the code still sees the value in the text box as "Mark". I've posted the section of the code below. I am sure I am just being dumb and missing something so hopefull one of you can point it out for me.
//loop thru the datagrid columns and update the datset
for (int i=2; i <= dsAds1.Ad.Columns.Count; i++)
{
//get the text box in the row
TextBox t = (e.Item.Cells.Controls[0]) as TextBox;
//get the column as a boundcolumn type
BoundColumn col = dgrdAds.Columns as BoundColumn;
//if the column and the textbox is not null update the text
//TODO Why are the textbox's coming back with old data?
if (col != null && t != null)
{
//if t holds a blank string insert dbnull
if (t.Text ==""
dsAds1.Ad[e.Item.DataSetIndex][col.DataField] = DBNull.Value;
else
dsAds1.Ad[e.Item.DataSetIndex][col.DataField] = t.Text;
}
That'l do donkey, that'l do
Mark
If you are unsure of forum etiquette check here faq796-2540
Got a bit of a situation here. I am reading an xml file into a dataset and throwing it into a datagrid for view/editing. Everything seems to work just fine except when I go to update a record. The edit button puts the grid into it's edit mode. I change some of the data and press update. Now I am successfully able to take the data in the textboxes and update the dataset with it (heres the problem) But the textboxes don't contain any of my updated data. If the text box originally had "Mark" in it and I changed it to "marc" the code still sees the value in the text box as "Mark". I've posted the section of the code below. I am sure I am just being dumb and missing something so hopefull one of you can point it out for me.
//loop thru the datagrid columns and update the datset
for (int i=2; i <= dsAds1.Ad.Columns.Count; i++)
{
//get the text box in the row
TextBox t = (e.Item.Cells.Controls[0]) as TextBox;
//get the column as a boundcolumn type
BoundColumn col = dgrdAds.Columns as BoundColumn;
//if the column and the textbox is not null update the text
//TODO Why are the textbox's coming back with old data?
if (col != null && t != null)
{
//if t holds a blank string insert dbnull
if (t.Text ==""
dsAds1.Ad[e.Item.DataSetIndex][col.DataField] = DBNull.Value;
else
dsAds1.Ad[e.Item.DataSetIndex][col.DataField] = t.Text;
}
That'l do donkey, that'l do
Mark
If you are unsure of forum etiquette check here faq796-2540