Can any one tell what i have to modify in the code
I have written code to add rows to the grid view dynamically at run time but the text on button Add is changing to the text on Delete button can any one have a look over the code and tell what i have to modify..


raghu v52 reputationPosted Jun 2, 2011, 4:30 AM EDT
in the function addnewrowtogrid
try with the following code
drCurrentRow["Add/Delete"] = "Add";
drCurrentRow["Add/Delete"] = "Delete";
and in setpreviousdata
use the code
box2.Text = "Add";
box3.Text = "Delete";
Posted Jun 2, 2011, 3:59 AM EDT
In AddNewRowToGrid function ,
the following code is wrong.
box2.Text = dt.Rows[i]["Add/Delete"].ToString();
box3.Text = dt.Rows[i]["Add/Delete"].ToString();
Here you're trying to use the same column value as two different varaible. There box3 value over writtern in box2 because
dt.Rows[i]["Add/Delete"].ToString().
So, change your logic here.
Dorababu MekaRank #457 · 5.5K reputationPosted Jun 2, 2011, 4:16 AM EDT
Posted Jun 2, 2011, 4:17 AM EDT
Check your datatable structure also...
box2.Text = dt.Rows[i]["Add"].ToString();
box3.Text = dt.Rows[i]["Delete"].ToString();
Dorababu MekaRank #457 · 5.5K reputationPosted Jun 2, 2011, 4:19 AM EDT
Dorababu MekaRank #457 · 5.5K reputationPosted Jun 2, 2011, 4:23 AM EDT
Posted Jun 2, 2011, 4:26 AM EDT
Try this
box2.Text = "Add";
box3.Text = "Delete";
Dorababu MekaRank #457 · 5.5K reputationPosted Jun 2, 2011, 4:34 AM EDT