Regarding ListItem Class

Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Closed Thread

Join Date: Jul 2004
Posts: 4
Reputation: cspek is an unknown quantity at this point 
Solved Threads: 0
cspek cspek is offline Offline
Newbie Poster

Regarding ListItem Class

 
0
  #1
Jul 31st, 2004
Hi All,
I am using a DropDownList in my page and I am binding the property of this server control like follows.
<%#DropDownList1.SelectedItem.Text%>
What I am finding is that it returns the text for the item I have selected. If I use the value property of the ListItem, then also it returns the text for the item I have selected.
In that case, what is the difference between the text property and the value property of the ListItem class??
I am sorry, if it is a very basic question..
Thanks and Regards,
CSPEK
Quick reply to this message  
Join Date: Feb 2002
Posts: 898
Reputation: Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light 
Solved Threads: 28
Moderator
Tekmaven's Avatar
Tekmaven Tekmaven is offline Offline
The C# Man, Myth, Legend

Re: Regarding ListItem Class

 
0
  #2
Jul 31st, 2004
Value is an object, which each list item has. When you create list items, you can assign a value object to them, and that object will stay with the list item (but not be displayed on the page).

The ideal use for this, is when you have a list of items that corrospond to ID numbers in a database. You would set the text property to the friendly description for the item, and the value to the ID number. When you go to interact with your database, you don't need to parse what ID number has been selected; because it's just in it's Value.
-Ryan Hoffman

.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
Quick reply to this message  
Join Date: Feb 2003
Posts: 793
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Solved Threads: 26
Team Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Regarding ListItem Class

 
0
  #3
Jul 31st, 2004
And to add to that just set the following from your connection to the DB:
     
'   |||||   Set the DataValueField to the Primary Key
DropDownList1.DataValueField = "ID"
' '   |||||   Set the DataTextField to the text/data you want to display
DropDownList1.DataTextField = "Details"

:lol:
Assistant Manager, Pharmacy Informatics
Wordpress Learning Blog
Updated : ASP.Net Login Code
Quick reply to this message  
Join Date: Jul 2004
Posts: 4
Reputation: cspek is an unknown quantity at this point 
Solved Threads: 0
cspek cspek is offline Offline
Newbie Poster

Re: Regarding ListItem Class

 
0
  #4
Aug 2nd, 2004
Yep,
Thanks...
cspek
Quick reply to this message  
Closed Thread

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC