Dynamically binding a Datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am doing an ASP.Net application wherein I have a datagrid which I need to
populate dynamically. The grid has 5 rows and two columns. In the 2nd col I
need to insert dropdown boxes. I'll have to populate both the cols from the
database. The values for the 2 cols come from 2 diff tables. How do I do this?

Also in the design mode, do I have to manually mention the Collections
property of the datagrid columns as Template Columns?

This is urgent. I'd appreciate if someone can help me.

Thanks
 
Probably the easiest way is to use a Connection object, a Data Adapter (one
for each table, in your case) and a DataSet. If you create a connection in
the server explorer (look on the left) you can drag a table from in there
onto your form and it will create the first two for you. Beyond that,
please reference the online help for binding a DataGrid to DataSet and it
should become pretty clear.

As far as the dropdown boxes, you are correct, you will want to make that a
template column.

In addition to http://msdn.microsoft.com I find that there's a lot of
helpful examples on some other web sites like http://www.codeproject.com
(free to sign up).
 
Back
Top