Retrieve the updated values from datagrid

Discussion in 'ASP .Net' started by =?Utf-8?B?TWFyeUE=?=, Aug 12, 2005.

  1. 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?
    =?Utf-8?B?TWFyeUE=?=, Aug 12, 2005
    #1
    1. Advertising

  2. "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.
    =?Utf-8?B?U2FjaGluIFNha2k=?=, Aug 12, 2005
    #2
    1. Advertising

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



    "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?
    =?Utf-8?B?RWx0b24gVw==?=, Aug 12, 2005
    #3
  4. 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.
    =?Utf-8?B?TWFyeUE=?=, Aug 13, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TmV3YXNwcw==?=
    Replies:
    0
    Views:
    689
    =?Utf-8?B?TmV3YXNwcw==?=
    Jun 12, 2004
  2. =?Utf-8?B?T3plcg==?=

    DataGrid.UpdateCommand I can't get updated values

    =?Utf-8?B?T3plcg==?=, Jun 12, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    538
    =?Utf-8?B?T3plcg==?=
    Jun 12, 2004
  3. Dmitry Korolyov

    Datagrid not updated during delete, but updated during insert and update

    Dmitry Korolyov, Sep 22, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    411
    Dmitry Korolyov
    Sep 22, 2003
  4. Dan

    DataGrid: OnUpdateCommand - getting the updated values

    Dan, Aug 18, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    142
  5. Chris Mahoney

    Get updated values from DataGrid

    Chris Mahoney, Sep 19, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    133
    Elton Wang
    Sep 20, 2005
Loading...

Share This Page