PDA

Click to See Complete Forum and Search --> : datagrid?


Techno
Sep 21st, 2004, 07:27 AM
How do i view the results of a table in a datagrid or dataresult? What do i do? :)

Mike Hildner
Sep 21st, 2004, 09:18 AM
You mean binding the data to your DataGrid? Windows Forms or web app? I've got some example in both if it will help.

Techno
Sep 21st, 2004, 09:25 AM
databind i think :) think i got it done but would like your example for a windows app :)

Mike Hildner
Sep 21st, 2004, 09:31 AM
private void RefreshData(string tableName)
{
dsThisTable = DataBase.GetTable(tableName);
dgSelectedTable.CaptionText = tableName;
dgSelectedTable.SetDataBinding(dsThisTable, tableName);
}


dsThisTable is a DataSet. dgSelectedTable is my DataGrid. DataBase.GetTable returns a DataSet (yeah, probably didn't name things quite right).

This is part of a generic form that gets all the user tables and views from a SQL Server DB, and populates a TreeView with their names. Then, when you click on a table/view, the DataGrid gets bound to that table/view. Quick little way to view/update any DB I point it to.

Mike