Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show Database table Items in DataGrid

Status
Not open for further replies.

jpreciado

MIS
Feb 7, 2004
36
MX
I'm new in c#. I have a DataGrid bounded to a DataSet. Everything works fine but I have to click first A PLUS SIGN AND THEN A table link to view the data.
Whow can I do to let the DataGrid shows directly the DataSet contents without clicking the plus sign and the table link?
 
i. set the datamember of the datagrid to be the table name you want to display.

Code:
dataGrid1.DataSource = dataSet;
dataGrid1.DataMember = dataSet.Tables[0].TableName;

ii. bind the datagrid to the table directly, setting its datasource either to the datatable or its dataview.

Code:
dataGrid1.DataSource = dataSet.Tables[0];

or

dataGrid1.DataMember = dataSet.Tables[0].DefaultView;

hope this helps,


mr s. <;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top