A
AA
We want to edit, update data of DataGrid in Asp.Net with VB.Net.and are
writing the following code for EditCommand and UpdateCommand
Event is :
DataGrid1_EditCommand
Code is:
DataGrid1.edititemindex=e.item.itemindex
DataGrid1.DataBind()
Event is :
DataGrid1_UpdateCommand
Code is:
Dim s as string
s=ctype(e.item.cells[2].Controls[0],textbox).text
Response.Write(s)
DataSet1.Tables(0).Rows(e.item.itemindex)(1)=s
Dim cmp as new SqlCommandBuilder(SqlDataAdapter1)
SqlDataAdapter1.update(DataSet1.Tables(0))
DataGrid1.EditItemIndex=-1
DataGrid1.DataBind()
This code does not show any error.
But there is problem,
when we modify any value of a record then
command [ s=ctype(e.item.cells[2].Controls[0],textbox).text ]
returns previous value.
If we write a fixed value in code to change it in datagrid then it updates
DataSet1.Tables(0).Rows(e.item.itemindex)(1)=HdDH This command updates
data in database
Therefore, problem is in retrieving current value from datagrid not in
updation command. How to access modified value of DataGrid
writing the following code for EditCommand and UpdateCommand
Event is :
DataGrid1_EditCommand
Code is:
DataGrid1.edititemindex=e.item.itemindex
DataGrid1.DataBind()
Event is :
DataGrid1_UpdateCommand
Code is:
Dim s as string
s=ctype(e.item.cells[2].Controls[0],textbox).text
Response.Write(s)
DataSet1.Tables(0).Rows(e.item.itemindex)(1)=s
Dim cmp as new SqlCommandBuilder(SqlDataAdapter1)
SqlDataAdapter1.update(DataSet1.Tables(0))
DataGrid1.EditItemIndex=-1
DataGrid1.DataBind()
This code does not show any error.
But there is problem,
when we modify any value of a record then
command [ s=ctype(e.item.cells[2].Controls[0],textbox).text ]
returns previous value.
If we write a fixed value in code to change it in datagrid then it updates
DataSet1.Tables(0).Rows(e.item.itemindex)(1)=HdDH This command updates
data in database
Therefore, problem is in retrieving current value from datagrid not in
updation command. How to access modified value of DataGrid