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

Answers


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.


Need Your Help

HTML table header with colspan when using jQuery DataTables

javascript jquery datatables

I try to use jQuery DataTables plugin, but it fails with message c is undefined on line 256 (in the minified version).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.