Click to See Complete Forum and Search --> : Table from Dataset to Datagrid


yusufozkay
September 7th, 2005, 07:02 AM
I have a table in a dataset and I want to show the first 6 rows of this table in a datagrid. How can I do this?

torrud
September 7th, 2005, 07:14 AM
//It is assumed that a datagrid and the dataset is instantiated and initialized
datagrid.SetDataBinding(myDataSet, myTableName);


For displaying the first 6 columns you have to use DataGridTableStyles and DataGridColumnStyles.

klintan
September 7th, 2005, 08:22 AM
If you can define an expression that is valid only for the first 6 rows you could create a dataview and bind the datagrid to it.

If not you need to create another datatable or a datarowcollection or a datarow array and put the first 6 rows into that object (I am not sure if all of them will work, I guess they should but I have not tried it).

I don't think you can achieve it with DataGridXxxStyles, but maybe someone else knows how to do that.

torrud
September 7th, 2005, 08:39 AM
I don't think you can achieve it with DataGridXxxStyles, but maybe someone else knows how to do that.

Oh, I misread the first posting. With the styles you can only design table columns not rows, of course. If only 6 rows should be displayed I would prefer one of the solutions descriped by klinton.