Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Retrieve the updated values from datagrid

Reply
Thread Tools

Retrieve the updated values from datagrid

 
 
=?Utf-8?B?TWFyeUE=?=
Guest
Posts: n/a
 
      08-12-2005
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?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2FjaGluIFNha2k=?=
Guest
Posts: n/a
 
      08-12-2005


"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.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RWx0b24gVw==?=
Guest
Posts: n/a
 
      08-12-2005
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
http://www.velocityreviews.com/forums/(E-Mail Removed)


"MaryA" wrote:

> 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?

 
Reply With Quote
 
=?Utf-8?B?TWFyeUE=?=
Guest
Posts: n/a
 
      08-13-2005
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

"Sachin Saki" wrote:

>
>
> "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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get updated values from DataGrid Chris Mahoney ASP .Net Datagrid Control 2 09-20-2005 03:43 PM
DataGrid: OnUpdateCommand - getting the updated values Dan ASP .Net Datagrid Control 0 08-18-2005 10:16 AM
DataGrid.UpdateCommand I can't get updated values =?Utf-8?B?T3plcg==?= ASP .Net 0 06-12-2004 10:27 PM
DataGrid.UpdateCommand Can't Get Updated Values From Textbox Contr =?Utf-8?B?TmV3YXNwcw==?= ASP .Net 0 06-12-2004 10:20 PM
Datagrid not updated during delete, but updated during insert and update Dmitry Korolyov ASP .Net Datagrid Control 0 09-22-2003 10:57 AM



Advertisments