iamguyster Posted October 24, 2003 Posted October 24, 2003 Hi, I have a drop-down list that is databound to a dataset. For the sake of this question the fields in the dataset are Field1, Field2, Field3 and Field4. In the Properties for the DDL I have previously set the the following values: DataTextField = Field1 DataValueField = Field4 Now I want to display in the Text of the DDL the following: Field2 - Field3, Field4 I understand that I can do this type of formatting in the DataTextFormatField but I can only get it to display the field entered into the DataTextField (using {0}). Can ayone tell me how to expose further fields to use in this property, so that I can enter for example, DataTextFormatField = {0} - {1}, {2} Thanks for any help on this. Cheers, IAmGuyster:D Quote
iamguyster Posted October 24, 2003 Author Posted October 24, 2003 Done and Done After a fair bit of searching, I found something that tells me I cannot expose two of the fields using the properties UI. Instead it has to be done programmatically. If anyone is interested I will post a smple of the code I used. It's very simple. Cheers, IAmGuyster Quote
Moderators Robby Posted October 24, 2003 Moderators Posted October 24, 2003 A simple solution would to format the Select from your DB... SELECT (F2 + ' - ' + F3 + ', ' + F4) as SomeF, F4 From .... Then do something like this... DataTextField = SomeF DataValueField = F4 Quote Visit...Bassic Software
devylzangel Posted October 30, 2003 Posted October 30, 2003 In the dataset where you are holding the dropdownlist data, you should be able to assign the text for the ddl by using the following structure to populate the ddl: {Assume the query returns the fields in this order: Field1, Field2, Field3, Field4, where field1 is item 0, field2 is item 1, etc.} {Also assume that the name of your drop down list is myddl} Dim myset as Dataset = [you dataset info here] Dim mytable As DataTable = myset.Tables(0) Dim j As Integer For j = 0 to mytable.rows.count - 1 Dim mylistitem As New System.Web.UI.WebControls.ListItem mylistitem.Text = mytable.Rows(j).Item(1) & " - " & mytable.rows(j).Item(2) & ", " & mytable.rows.Item(3) mylistitem.Value = mytable.Rows(j).Item(1) myddl.Add(mylistitem) mylistitem = Nothing Next Hope this helps! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.