Datagrid updation


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
 
Ad

Advertisements

G

Guest

Hi

It looks like that you bind the grid before updating
Do you do a databind in page_load event

Bin Song, MC

----- AA wrote: ----

We want to edit, update data of DataGrid in Asp.Net with VB.Net.and ar

writing the following code for EditCommand and UpdateComman



Event is

DataGrid1_EditComman

Code is

DataGrid1.edititemindex=e.item.iteminde

DataGrid1.DataBind(

Event is

DataGrid1_UpdateComman

Code is

Dim s as strin

s=ctype(e.item.cells[2].Controls[0],textbox).tex

Response.Write(s

DataSet1.Tables(0).Rows(e.item.itemindex)(1)=

Dim cmp as new SqlCommandBuilder(SqlDataAdapter1

SqlDataAdapter1.update(DataSet1.Tables(0)

DataGrid1.EditItemIndex=-

DataGrid1.DataBind(



This code does not show any error

But there is problem

when we modify any value of a record the

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 update

DataSet1.Tables(0).Rows(e.item.itemindex)(1)=HdDH This command update

data in databas

Therefore, problem is in retrieving current value from datagrid not i

updation command. How to access modified value of DataGri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top