Grid delete problem
-
I have a datagrid with a delete function... my problem is that the table in the database have three keys... how do I set the datakey value in this regard to be able to delete? Thanks alot, commickey
1. Bind all three keys to the datagrid. 2. In ItemCommand event of datagrid , check for delete command eg.. switch(e.CommandName) { case "Delete": break; } 3. In the case "Delete" Find the controls and fetch values from the three key columns if you use a Template column for them in datagrid. eg. TextBox txt = new TextBox(); txt = (TextBox)e.Item.FindControl("txtKey1"); OR IF these three key columns are BoundColumn in datagrid then get values using following eg. e.Item.Cells[3] 4. Once you get all three key values you can delete this record by developing a sql query which will use these values to delete the record. praveen.
-
1. Bind all three keys to the datagrid. 2. In ItemCommand event of datagrid , check for delete command eg.. switch(e.CommandName) { case "Delete": break; } 3. In the case "Delete" Find the controls and fetch values from the three key columns if you use a Template column for them in datagrid. eg. TextBox txt = new TextBox(); txt = (TextBox)e.Item.FindControl("txtKey1"); OR IF these three key columns are BoundColumn in datagrid then get values using following eg. e.Item.Cells[3] 4. Once you get all three key values you can delete this record by developing a sql query which will use these values to delete the record. praveen.
-
1. Bind all three keys to the datagrid. 2. In ItemCommand event of datagrid , check for delete command eg.. switch(e.CommandName) { case "Delete": break; } 3. In the case "Delete" Find the controls and fetch values from the three key columns if you use a Template column for them in datagrid. eg. TextBox txt = new TextBox(); txt = (TextBox)e.Item.FindControl("txtKey1"); OR IF these three key columns are BoundColumn in datagrid then get values using following eg. e.Item.Cells[3] 4. Once you get all three key values you can delete this record by developing a sql query which will use these values to delete the record. praveen.
-
1. Bind all three keys to the datagrid. 2. In ItemCommand event of datagrid , check for delete command eg.. switch(e.CommandName) { case "Delete": break; } 3. In the case "Delete" Find the controls and fetch values from the three key columns if you use a Template column for them in datagrid. eg. TextBox txt = new TextBox(); txt = (TextBox)e.Item.FindControl("txtKey1"); OR IF these three key columns are BoundColumn in datagrid then get values using following eg. e.Item.Cells[3] 4. Once you get all three key values you can delete this record by developing a sql query which will use these values to delete the record. praveen.