ListItem VALUE -I can not set with code (taking text property

ListItem VALUE -I can not set with code (taking text property

Post by Um9u » Fri, 08 Oct 2004 22:53:06


Thanks this helped a lot. Just FYI for the readers, I was binding the data
on the HTML side and that is where I was making the mistakes. With your
info, I figured this out and it worked fine. Creating the ListItemCollection
the same way you did in sub Bind_Data(), I then binded the collection to the
DropDownList inside the tag like this:

<asp:DropDownList
ID="SomeID"
Runat="server"
DataSource="<%# items %>"
DataValueField='<%# "Value" %>'
DataTextField='<%# "Text" %>'>
</asp:DropDownList>

Before, I did not have the DataValueField or DataTextField attributes set.
If anyone uses this DropDownList Example, they should note the single quotes
used with DataValueField and DataTextField (and the double quotes around the
Value and Text fields). I guess I did not realize that 'Value' and 'Text'
were "Field Names" of the ListItem.

Thanks again, this was a big help.
 
 
 

ListItem VALUE -I can not set with code (taking text property

Post by v-schan » Sat, 09 Oct 2004 10:34:03

Hi Ron,

You're welcome. I'm also glad that my suggestions has been of assistance.
Thanks again for posting and please always feel free to post here when you
need any help on asp.net:).

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)