DropdownList in EditTemplate

Discussion in 'ASP .Net' started by Yan Wang, May 23, 2004.

  1. Yan Wang

    Yan Wang Guest

    I can populate the dropdown box in a edittemplate correctly. I can even
    have the dropdown preselect the correct value returned from my
    database. However, I cannot capture the selected value when I edit the
    column. It always updated the column to the first item in the list
    regardless of
    what I select when it is in edit mode. Anyone has the same problem?

    Thanks a lot!
     
    Yan Wang, May 23, 2004
    #1
    1. Advertising

  2. Yan Wang

    Jos Guest

    Yan Wang wrote:
    > I can populate the dropdown box in a edittemplate correctly. I can
    > even have the dropdown preselect the correct value returned from my
    > database. However, I cannot capture the selected value when I edit the
    > column. It always updated the column to the first item in the list
    > regardless of
    > what I select when it is in edit mode. Anyone has the same problem?
    >
    > Thanks a lot!


    On postback, make sure the datagrid or datalist is re-created in the
    same way, with the same dropdown lists present (a control can
    not restore its state when it's not there anymore).
    This means that you need to databind the grid on postback too
    (you can do this in Page_Load). Don't preselect the correct value
    this time, the value will be restored from the postback automatically.

    Then you can handle the postback (probably in the "UpdateCommand"
    event).

    Finally, you may bind the datagrid or list again, depending on what
    you want to show after postback.

    --

    Jos
     
    Jos, May 23, 2004
    #2
    1. Advertising

  3. Yan Wang

    Natty Gur Guest

    Hi,


    Ensure that you dont refill your grid on postback. you can use page
    ispostback to determine if your page called for the first time or its
    postback call.

    Natty Gur[MVP]

    blog : http://weblogs.asp.net/ngur
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Natty Gur, May 24, 2004
    #3
    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. Antonio D'Ottavio
    Replies:
    2
    Views:
    2,134
    =?Utf-8?B?RWx0b24gVw==?=
    Sep 26, 2005
  2. Krish

    EditTemplate - Dropdownlist

    Krish, Sep 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    560
    Krish
    Sep 21, 2005
  3. Jan
    Replies:
    2
    Views:
    678
  4. ES
    Replies:
    0
    Views:
    933
  5. Joe Reiss

    Formview EditTemplate Dropdownlist

    Joe Reiss, Feb 20, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    137
    Joe Reiss
    Feb 20, 2007
Loading...

Share This Page