Retrieve the updated values from datagrid

G

Guest

I have an asp.net application in which i have a form containing a datagrid
when using the update command event i have:
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
subject = tb.Text
this code is supposed to get the new data entered in the text box but i am
getting the old data why?
 
G

Guest

"MaryA" ने लिखा:
I have an asp.net application in which i have a form containing a datagrid
when using the update command event i have:
tb = CType(e.Item.Cells(3).Controls(0), TextBox)
subject = tb.Text
this code is supposed to get the new data entered in the text box but i am
getting the old data why?

In this case, use FindControl method Instead of tb =
CType(e.Item.Cells(3).Controls(0), TextBox)
like this
Dim txt as textbox = CType(e.item.FindControl("Id of textbox"),textbox)

I hope this will work in all cases. if you are loop through the datagrid
then its best way to do for each row.
 
G

Guest

Hi Mary,

Most likely reason is that you re-bind the datagrid’s data source, hence
data inputted is overwritten by data from database (old value).

HTH

Elton Wang
(e-mail address removed)
 
G

Guest

Sachin thanks for your reply but i cant use this:CType(e.item.FindControl("Id
of textbox"),textbox) coz in datagrid textboxes are created automaticly when
clicking the edit mode so they dont have an index
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top