Hi Kuldeep,
With these lines of code u would be able to do it....
private void datagrid1_EditC ommand(object source, System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
datagrid1.EditI temIndex = e.Item.ItemInde x;
datagrid1.DataB ind();
}
private void datagrid1_Delet eCommand(object source, System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
SqlCommandBuild er cb=new SqlCommandBuild er(DataAdapterO bject);
// Delete Corresponding row
ds.Tables [0].Rows [e.Item.DataSetI ndex].Delete();
DataAdapterObje ct.Update (ds);
Page.DataBind ();
}
private void datagrid1_Cance lCommand(object source, System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
datagrid1.EditI temIndex = -1;
datagrid1.DataB ind();
}
private void datagrid1_Updat eCommand(object source, System.Web.UI.W ebControls.Data GridCommandEven tArgs e)
{
TableCell tc = e.Item.Cells[2];
string s = ((TextBox)tc.Co ntrols[0]).Text;
ds.Tables[0].Rows[e.Item.DataSetI ndex]["Role"] = s;
SqlCommandBuild er scb = new SqlCommandBuild er(DataAdapterO bject);
DataAdapterObje ct.Update(ds);
// Edit operation should be cancelled
datagrid1.EditI temIndex = -1;
datagrid1.DataB ind();
}
But i think your problem is different because that much u can get in help document also. So reply it u need something different.
Pooja Shukla
Hi all
I want to know that how to edit,Delete and cancel data in datagrid using c#. Any body would like to help me plz for this.
kuldeep singh sethi