ListItem attributes in DropDownList not being persisted

Discussion in 'ASP .Net Web Controls' started by Bob Krug, Oct 4, 2003.

  1. Bob Krug

    Bob Krug Guest

    I have a DropDownList control to which I am adding 2 ListItems. For each
    List Item I am setting the Value and Text as well as adding an attribute.
    My code looks something like this:

    Dim objItem as new ListItem
    objItem.value = "1"
    objItem.Text = "Value 1"
    objItem.attributes("CrossRefValue") = "A"

    MyDropList.items.add(objItem)

    I do the same thing for the second item in the drop list. The problem is
    that the attributes no longer exist after postback. The text & value
    properties are still there, but no attributes. If I apply attributes to a
    TextBox they persist between postbacks, why not the list items? Are
    attributes not really supported for drop list items? I looked at the html
    source of the rendered page and I don't see my attributes as part of the
    "options" tag of the select object.

    Thanks,
    Bob
    Bob Krug, Oct 4, 2003
    #1
    1. Advertising

  2. Bob Krug

    mbalam Guest

    do you have viewstate = true ?
    >-----Original Message-----
    >I have a DropDownList control to which I am adding 2

    ListItems. For each
    >List Item I am setting the Value and Text as well as

    adding an attribute.
    >My code looks something like this:
    >
    >Dim objItem as new ListItem
    >objItem.value = "1"
    >objItem.Text = "Value 1"
    >objItem.attributes("CrossRefValue") = "A"
    >
    >MyDropList.items.add(objItem)
    >
    >I do the same thing for the second item in the drop

    list. The problem is
    >that the attributes no longer exist after postback. The

    text & value
    >properties are still there, but no attributes. If I

    apply attributes to a
    >TextBox they persist between postbacks, why not the list

    items? Are
    >attributes not really supported for drop list items? I

    looked at the html
    >source of the rendered page and I don't see my attributes

    as part of the
    >"options" tag of the select object.
    >
    >Thanks,
    >Bob
    >
    >
    >
    >.
    >
    mbalam, Oct 4, 2003
    #2
    1. Advertising

  3. Bob Krug

    Bob Krug Guest

    Yes. Probably should have mentioned that, but I do have viewstate = true.
    The list item values/text are coming back fine.


    "mbalam" <> wrote in message
    news:089801c38a2a$c21aed70$...
    > do you have viewstate = true ?
    > >-----Original Message-----
    > >I have a DropDownList control to which I am adding 2

    > ListItems. For each
    > >List Item I am setting the Value and Text as well as

    > adding an attribute.
    > >My code looks something like this:
    > >
    > >Dim objItem as new ListItem
    > >objItem.value = "1"
    > >objItem.Text = "Value 1"
    > >objItem.attributes("CrossRefValue") = "A"
    > >
    > >MyDropList.items.add(objItem)
    > >
    > >I do the same thing for the second item in the drop

    > list. The problem is
    > >that the attributes no longer exist after postback. The

    > text & value
    > >properties are still there, but no attributes. If I

    > apply attributes to a
    > >TextBox they persist between postbacks, why not the list

    > items? Are
    > >attributes not really supported for drop list items? I

    > looked at the html
    > >source of the rendered page and I don't see my attributes

    > as part of the
    > >"options" tag of the select object.
    > >
    > >Thanks,
    > >Bob
    > >
    > >
    > >
    > >.
    > >
    Bob Krug, Oct 4, 2003
    #3
  4. Hi Bob,

    Based on my research and experience, this issue is a limitation. Please
    refer to the following URL for the detailed information:

    http://www.dotnet247.com/247reference/msgs/13/68348.aspx

    Does it answer your question?

    If I have misunderstood your concern, please feel free to let me know.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Oct 6, 2003
    #4
  5. Bob Krug

    Bob Krug Guest

    Yes, that is the information I am looking for! The only other question is
    how do I find out when the problem has been fixed? I would like to stop
    using my "custom" drop list when MS has fixed the limitation - Is there some
    sort of mailing list I can get on for resolution of known issues?

    Thanks,
    Bob

    "Jacob Yang [MSFT]" <> wrote in message
    news:...
    > Hi Bob,
    >
    > Based on my research and experience, this issue is a limitation. Please
    > refer to the following URL for the detailed information:
    >
    > http://www.dotnet247.com/247reference/msgs/13/68348.aspx
    >
    > Does it answer your question?
    >
    > If I have misunderstood your concern, please feel free to let me know.
    >
    > Best regards,
    >
    > Jacob Yang
    > Microsoft Online Partner Support
    > Get Secure! ¨C www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
    Bob Krug, Oct 6, 2003
    #5
  6. Hi Bob,

    I am very glad to know that the information is helpful to you. For your
    last question, unfortunately, there is not such a mailing list. In general,
    there will be a published Knowledge Base article when a known issue is
    fixed. Please pay more attention to the Microsoft Web Site. Thank you for
    your understanding.

    In addition, you can send feedback for our products via the following URL:

    http://register.microsoft.com/mswish/suggestion.asp?&SD=GN&LN=EN-US&gssnb=1

    I hope it helps.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Oct 7, 2003
    #6
  7. Hi Bob,

    Please pardon my last post. I wrote "Please pay more attention to the
    Microsoft Web Site". I realize that our web site is too large to watch
    closely. I have an additional suggestion for you. Watch for updates to the
    NET framework, such as service packs. Each time you install one, retest
    this issue.

    With this you have two ways to watch for this being fixed; watch for an
    article and retest after installing updates. Between these methods, you
    should become aware of the fix shortly after it is made available.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Oct 8, 2003
    #7
    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. Toby Mills
    Replies:
    0
    Views:
    1,556
    Toby Mills
    Jun 24, 2003
  2. VB Programmer

    Dataset not persisted on PostBack

    VB Programmer, Jun 5, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    385
    =?Utf-8?B?SmltIEhldmV5?=
    Jun 6, 2004
  3. Mad Scientist Jr
    Replies:
    2
    Views:
    429
    Mad Scientist Jr
    Jun 29, 2004
  4. Karl
    Replies:
    0
    Views:
    760
  5. Jim in Arizona
    Replies:
    7
    Views:
    901
    Badass Scotsman
    Nov 22, 2006
Loading...

Share This Page