I have a dataset table with rows and columns extracted. I want to display one of the column values( Dates) from the dataset in a dropdown list. Here is the code i have written for filling dates into drop down list. The problem is there are similar dates, I want unique dates to be filled..
Public void fillDates()
{
DataSet ds = new DataSet();
ds = bal.selectDateOfTest(qstrng);
ddlTestDate.Items.Clear();
ddlTestDate.Items.Add(new ListItem("--Select--", "0"));
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
ddlTestDate.Items.Add(new ListItem(
Convert.ToString(ds.Tables[0].Rows[i][0]).Trim(),
Convert.ToString(ds.Tables[0].Rows[i][0])));
}
You need to adapt your query that returns all dates to group the dates, this would be the best approach.
Alternatively, you could implement code that does the grouping after it has been returned from the database.