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
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:
<asp:DropDownList ID="cboHotel" runat="server"
DataValueField="ID"
DataTextField="HotelName" Width="288px"
style="font-family:courier, 'courier new', monospace;"
></asp:DropDownList>
And to fill, we do this:
strSQL = "SELECT ID, HotelName, City "
"FROM tblHotels ORDER BY HotelName";
DataTable rst = MyRst(strSQL);
rst.Columns[1].MaxLength = 255;
foreach (DataRow MyRow in rst.Rows)
{
MyRow["HotelName"] = ((String)MyRow["HotelName"]).PadRight(35, '\u00A0')
" | " MyRow["City"];
}
cboHotel.DataSource = rst;
cboHotel.DataBind();
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.