Error Fetching Custom Attribute Value from HtmlSelect

Tech-Archive recommends: Speed Up your PC by fixing your registry



I'm using an HtmlSelect (runat=sever).

I add the items programmatically and I also add a custom attribute to
each listitem because I need to track an additional field value.

I'm having a problem getting that attribute value upon postback. I keep
getting a null reference error. I was under the impression that the
attribute collection is saved in viewstate.

My code to get the attribute value is:

string val=
mySelect.Attributes["attrname"][mySelect.SelectedIndex].ToString();

What am I doing wrong?

Thanks.
Lisa

.



Relevant Pages

  • RE: Inherit ListItem?
    ... to customize the ListItem so as to add additional properties, ... duplicate these two classes' code and add your custom codelogic (such as ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Retrieving value of a custom tag
    ... concepts revolves around a custom dropdownlist class. ... Private Sub Page_Load(ByVal sender As System.Object, ... Dim liCol As ListItemCollection ... Dim item As ListItem ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Retrieving value of a custom tag
    ... The other thing I was attempting to do was create a modified ListItem Class ... concepts revolves around a custom dropdownlist class. ... Private Sub Page_Load(ByVal sender As System.Object, ... Dim liCol As ListItemCollection ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Retrieving value of a custom tag
    ... access to its attributes (ListItem implements this interface). ... concepts revolves around a custom dropdownlist class. ... Private Sub Page_Load(ByVal sender As System.Object, ... Dim liCol As ListItemCollection ...
    (microsoft.public.dotnet.framework.aspnet)