Problem with DropDown in EditItem of Datagrid!

Discussion in 'ASP .Net' started by Lars Netzel, Jul 30, 2004.

  1. Lars Netzel

    Lars Netzel Guest

    Hello!

    When you Click Edit of a DataGrid row I, in EditCommand sub, set the right
    Index and recnid the DataGrid.

    In ItemCreated (of that Bind) I fill a DropDownlist ( buy adressing it with
    ItemIndex and FindControl) and set the Selected Value to the Value I want.
    So Far everything is Fine, if I debug and step thru the code.. it fills and
    the Selected Value is the right value.

    But Then when the page shows... the Selected Item is not the Item with the
    SelectedValue.. it's the first in the DropDown box.. as if nothing was
    selected. But the Dropdownbox is filled with the right stuff, just not
    selected with the value I set (and saw in the debug that it was set)

    Since this is VB I can't debug the Data Itself so I tried Setting a
    breakpoint in EVERY function and Sub I had in the Form and se if the
    DropDownlist accidentley resetted somehow somewhere.. but I can't really
    find any place where the Selected Value is overwritten or anything---

    I have no idea where to look for answers now.. please help!

    Best Regards
    /Lars
     
    Lars Netzel, Jul 30, 2004
    #1
    1. Advertising

  2. Lars Netzel

    Lars Netzel Guest

    They actually tell how to do it here..

    http://aspnet.4guysfromrolla.com/articles/080702-1.3.aspx

    But It's strange to me that they do it in the HTML and not in ItemCreated..
    I guess it has to do in what order things happen... an dI guess ItemCreated
    in not the right tiem to set the SelectedIndex..

    I got it working though, with their technique...

    /Lars


    "Lars Netzel" <[stop_spam]@host.topdomain> skrev i meddelandet
    news:...
    > Hello!
    >
    > When you Click Edit of a DataGrid row I, in EditCommand sub, set the right
    > Index and recnid the DataGrid.
    >
    > In ItemCreated (of that Bind) I fill a DropDownlist ( buy adressing it

    with
    > ItemIndex and FindControl) and set the Selected Value to the Value I want.
    > So Far everything is Fine, if I debug and step thru the code.. it fills

    and
    > the Selected Value is the right value.
    >
    > But Then when the page shows... the Selected Item is not the Item with the
    > SelectedValue.. it's the first in the DropDown box.. as if nothing was
    > selected. But the Dropdownbox is filled with the right stuff, just not
    > selected with the value I set (and saw in the debug that it was set)
    >
    > Since this is VB I can't debug the Data Itself so I tried Setting a
    > breakpoint in EVERY function and Sub I had in the Form and se if the
    > DropDownlist accidentley resetted somehow somewhere.. but I can't really
    > find any place where the Selected Value is overwritten or anything---
    >
    > I have no idea where to look for answers now.. please help!
    >
    > Best Regards
    > /Lars
    >
    >
     
    Lars Netzel, Jul 30, 2004
    #2
    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. Shane O. Pinnell
    Replies:
    0
    Views:
    455
    Shane O. Pinnell
    Jul 9, 2003
  2. Olivier Matrot

    Default button in Datagrid EditItem

    Olivier Matrot, May 24, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,254
    Brock Allen
    May 24, 2005
  3. Shane O. Pinnell

    Error Binding DropDownList on EditItem Command of DataGrid Control

    Shane O. Pinnell, Jul 9, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    187
    Shane O. Pinnell
    Jul 9, 2003
  4. Dave56

    DataGrid EditItem ClientID

    Dave56, Dec 1, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    8
    Views:
    190
    Prodip Saha
    Dec 12, 2003
  5. James Cooke
    Replies:
    0
    Views:
    250
    James Cooke
    Sep 11, 2008
Loading...

Share This Page