As of now i can only display the 1 row but i also want to add the other row in my dropdown
This is my code
enter image description here
This is my code in text field and value field
DropTeam.DataSource = dtt;
DropTeam.DataValueField = "TeamDescr"+"TeamCode";
DropTeam.DataTextField = "TeamDescr"+"TeamCode";
DropTeam.DataBind();
3
Answers
You have to provide the table name in the Fill function and Fill expect a DataSet instead of DataTable so it should be like this
sd.Fill(ds,"Branch")
here how to use DataSet with DataTable
You can use a while:
Well, a typical dropdown (combo) will let you select a row. Typical a combo box can let you choose one row for display, and then "usually" the PK row.
So the PK row selection should REMAIN the PK row value, but for display? Unlike say a access combo, there is no multiple column support for more then one row.
So, what you can do is simple concatenation of the additonal columns.
Say we have drop down for hotel Name. We have say this:
To display say Hotel name and city in the drop?
You could go like this:
The drop will will only return for you the one PK value (ID). From that value, you can then get/use/derive the actual city name from that combo.
So markup:
code:
output:
And you could add a fixed font size.
(but the drop down HTML will remove those blanks).
But, you can get around that issue by padding in ‘u00A0’ chars.
So, lets adopt a fixed font, and do this:
And to fill, we do this:
So, we just pre-process the table data, and we now get this:
Now, any selected row will ONLY return the PK value, and then you can get the City name, tax rate or anything else from that combo selection.
The 3rd way? You would "fake" the drop down, and pop down (display) a grid view with all the columns. But, I not posted that solution unless it comes to light that either of the above two ideas will not suffice.