Click here to Skip to main content
15,843,319 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have this code:

protected void Page_Load(object sender, EventArgs e)
           DataTable dt = GetTable();

           dt2.DataSource = dt;

           ddl.DataSource = dt;
           ddl.DataTextField = "Author";
           ddl.DataValueField = "Author";
           ddl.Items.Insert(0, "All");

       static DataTable GetTable()
           DataColumn col = new DataColumn();

           DataTable table = new DataTable();

           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?

1 solution

Filtering can be done on the data source only, so you can either use a bindingsource or the data table that is bound to datagridview. This link has plenty of ways to filter a datagridview but all use some or the other form binding source:[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900