How a grid can be made editable int ASP.Net? How to Access a particular cell of Grid?What is the difference between datagrid and datalist?

Questions by ashishmisra78   answers by ashishmisra78

Showing Answers 1 - 2 of 2 Answers

rspsuba

  • Jul 8th, 2006
 

to make the grid editablepublic void bind() { string str = "select * from Customer"; OleDbDataAdapter da = new OleDbDataAdapter(str,con); DataSet ds = new DataSet(); da.Fill(ds); dg.DataSource = ds;// this reference is used to identify keys in grid dg.DataKeyField="CustID"; dg.DataBind(); } then create an event for grid!for update,edit,deleteprivate void dg_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { dg.EditItemIndex = e.Item.ItemIndex; bind(); // this value is used to mention the respective row of grid idval = dg.DataKeys[(int)e.Item.ItemIndex].ToString(); }

  Was this answer useful?  Yes

rspsuba

  • Jul 8th, 2006
 

public void bind() { string str = "select * from Customer"; OleDbDataAdapter da = new OleDbDataAdapter(str,con); DataSet ds = new DataSet(); da.Fill(ds); dg.DataSource = ds; // this keyfield is used to identify records dg.DataKeyField="CustID"; dg.DataBind(); } private void dg_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { dg.EditItemIndex = e.Item.ItemIndex; bind(); //this is value for identifyin current row idval = dg.DataKeys[(int)e.Item.ItemIndex].ToString(); }regards ! rajikiran!

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions