I have this code:
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = GetTable();
dt2.DataSource = dt;
dt2.DataBind();
ddl.DataSource = dt;
ddl.DataTextField = "Author";
ddl.DataValueField = "Author";
ddl.DataBind();
ddl.Items.Insert(0, "All");
}
static DataTable GetTable()
{
DataColumn col = new DataColumn();
DataTable table = new DataTable();
table.Columns.Add("ISBN",typeof(string));
table.Columns.Add("Name",typeof(string));
table.Columns.Add("Author",typeof(string));
table.Columns.Add("Year",typeof(string));
table.Rows.Add("9780471678403", "Acoustic Echo and Noise Control", "Hansler", "2000");
table.Rows.Add("9780470544068", "Active Antennas and Quasi-Optical Arrays", "Tsoulus", "2001");
table.Rows.Add("9780470396360", "Algorithms and Protocols for wireless Sensor Networks", "Boukerche", "2002");
col = table.Columns["Author"];
return table;
}
it is a simple example, but i need to filter the data and all the examples i looked for ont he internet all included dataset and staff.
If i put a drop down list, having to show me only the authors which i choose, i cannot do it with this type of code? Do i have to use datasets for sure?