It looks like (as Peter is guessing) that you are selecting Rows out of a DataTable? If so, do this:
Me.drp3.DataTextField = "topic" Me.drp3.DataValueField = "skillid" Me.drp3.DataSource = dtSkill Use a DataView if you want just a subset of those rows to display. Greg ---------------------------------------- From: Maya Tulchinsky <[EMAIL PROTECTED]> Sent: Wednesday, September 01, 2004 5:59 AM To: [EMAIL PROTECTED] Subject: re: [AspNetAnyQuestionIsOk] Dropdownlist - how to store id help needed Unfortunately same result with this code and I received an error on the databind() - 'System.Data.DataRow' does not contain a property with the name topic. But when looping through datarow - I can retrieve value "topic" Any ideas? Greg Ewing wrote: Maya, when you are using Databinding (which you are with DataTextField and DataValueField) you only need to set the values once, not loop through your dataRow collection. Also, the DataTextField is the column name which should be assigned to the Text portion of your dropdown box. The same is true for DataValueField in that it's just the column name. In this case you will do something like this: Dim dRow3() As DataRow = dtSkill.Select(sSelect) Me.drp3.DataTextField = "topic" Me.drp3.DataValueField = "skillid" Me.drp3.DataSource = dRow3 Greg Ewing [MVP] www.citidc.com ---------------------------------------- From: Maya Tulchinsky Sent: Wednesday, September 01, 2004 5:25 AM To: [EMAIL PROTECTED] Subject: [AspNetAnyQuestionIsOk] Dropdownlist - how to store id help needed Can anybody tell me what is wrong with a code: Dim dRow3() As DataRow = dtSkill.Select(sSelect) For Each dr In dRow3 Me.drp3.DataTextField = dr.Item("topic").ToString Me.drp3.DataValueField = dr.Item("skillid").ToString Next When in debug mode I can see that there are values coming from the datatable, but it does not get stored in dropdownlist. If I use the following line: Me.drp3.Items.Add(dr.Item("topic").ToString()) It is working, but I also need to store ID, not only description. Thank you for your time. Maya --------------------------------- Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! [Non-text portions of this message have been removed] Yahoo! Groups Links [Non-text portions of this message have been removed] Yahoo! Groups Sponsordocument.write(''); --------------------------------- Yahoo! Groups Links To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ To unsubscribe from this group, send an email to: [EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. --------------------------------- Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! [Non-text portions of this message have been removed] Yahoo! Groups Links [Non-text portions of this message have been removed] ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/saFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/