How to populate the rows of a gridview at runtime?
Hi,
am working on a web-application with a database behind it. I would like to be able to populate the rows of a gridview at runtime, means based on a certain condition I need to decide, if a particular Row from the database should be displayed or not.
I tried selectively adding the rows to DataTable first, and then binding the DataTable to the GridView, but didn't work. The Code is below..
/*
StudentTableAdapter adapter = new StudentTableAdapter();
DataTable table = new DataTable();
foreach (DataRow row in adapter.GetStudentMarks())
{
String Branch = row["ProjectName"].ToString();
if (Branch.Equals("Computer-Science"))
{
table.Rows.Add(row);
}
}
GridView1.DataSource = table;
GridView1.DataBind();
*/
Thanks in advance.