DataValueField - postback

Discussion in 'ASP .Net Web Controls' started by Mike, Sep 4, 2003.

  1. Mike

    Mike Guest

    I haven't been able to find any posts about this problem.
    When I set the DataValueField to be something, the control
    loses it's selected index when returning from the
    postback. If I set only the DataTextField I have no
    problems.

    I set the DataTextField and DataValueFields like so:

    ddlBU.DataTextField="BU"; -- each value is unique
    ddlBU.DataValueField = "ORG_ID"; -- is 1 of 2 values

    It seems that the because Org_Id is not unique in the
    dataset it is screwing up the index of the control by
    setting the SelectedIndex to be the first ListItem it
    finds with a DataValueField matching that of the
    originally selected item.

    Anyone know of a work around ?
     
    Mike, Sep 4, 2003
    #1
    1. Advertising

  2. Mike

    Alvin Bruney Guest

    why don't you manually set the selected item to the value of the item you
    are looking for
    selectedindex = 9; for 10th item
    "Mike" <> wrote in message
    news:22f101c3732a$ce92e560$...
    > I haven't been able to find any posts about this problem.
    > When I set the DataValueField to be something, the control
    > loses it's selected index when returning from the
    > postback. If I set only the DataTextField I have no
    > problems.
    >
    > I set the DataTextField and DataValueFields like so:
    >
    > ddlBU.DataTextField="BU"; -- each value is unique
    > ddlBU.DataValueField = "ORG_ID"; -- is 1 of 2 values
    >
    > It seems that the because Org_Id is not unique in the
    > dataset it is screwing up the index of the control by
    > setting the SelectedIndex to be the first ListItem it
    > finds with a DataValueField matching that of the
    > originally selected item.
    >
    > Anyone know of a work around ?
     
    Alvin Bruney, Sep 8, 2003
    #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. Parodi Development
    Replies:
    0
    Views:
    3,669
    Parodi Development
    Sep 10, 2004
  2. =?Utf-8?B?UkY=?=

    Concatenating Multiple Values for DataValueField

    =?Utf-8?B?UkY=?=, Dec 2, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    7,385
    Marina
    Dec 3, 2004
  3. =?Utf-8?B?U3VuaWwgU2FiaXI=?=

    Advantage of DataValueField

    =?Utf-8?B?U3VuaWwgU2FiaXI=?=, Feb 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,562
    Eliyahu Goldin
    Feb 1, 2005
  4. Sam
    Replies:
    1
    Views:
    12,086
    Eliyahu Goldin
    Feb 18, 2005
  5. tshad
    Replies:
    3
    Views:
    4,588
    tshad
    May 10, 2005
Loading...

Share This Page