I have a DataTable called cachedData.
It values like this
| COL1 | COL2 |
| -------- | -------------- |
| 12 |- |
| -| 59|
| 32 |- |
| -| 63|
I want to set these values to a dropdown without considering these as two columns.
Ex : dropdown values should be 12,59,32,63
I tried but this gives me an error.Please help me to bind this dataTable values to dropdown
if (cachedData != null)
{
this.DigitalChannelSignatureDropDownList.DataTextField = "COL1"+"COL2";
this.DigitalChannelSignatureDropDownList.DataValueField = "COL1"+"COL2";
this.DigitalChannelSignatureDropDownList.DataSource = cachedData;
this.DigitalChannelSignatureDropDownList.DataBind();
}
Well, it is not clear what the "-" values are in your table?
However, you could use a union query, and say this:
The output of above then becomes this:
And perhaps your '-' was for null values, so change the above SQL to:
So, now to load up the drop-down list, we have this:
Markup:
And code behind is thus this:
And of course, code to return a datatable from the SQL can be this: