How does one dynamically add a new datalist or a row to a gridview?
To be able to dynamically add a new datalist or a row to a gridview when placed in a foreach loop for example I have an SQL query that outputs the values for each time an ID number is in a list, but I need to a way to output them…
So could I create a new datalist or row for each one created?? Or is there another way to achieve this
First filter the list, then assign it to your GridView DataSource:
myGridView.DataSource = yourList.Where(i => i.TheID == 123); myGridView.DataBind();
That will automatically create a row for each list item.