By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,120 Members | 1,799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,120 IT Pros & Developers. It's quick & easy.

Datagrid updation

P: n/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
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.