Hi.
I am showing a column on a datagridview. The codes are below;
DataTable table_nmrlr = new DataTable();
adapter_nmrlr.Fill(table_nmrlr);
...
dataGridView3.DataSource = table_nmrlr;
First column has 10 row. Then I want to show another column on datagridview on under the other. I mean the second column must start at 11.th row. But I couldnt do this. There should be 2 column on the same datagridview's column. How can I do this?
Loading
Nilanka DharmadasaPosted Nov 13, 2009, 12:02 AM
One thing i forgot. In the previous reply, replace 'union' word with 'union all'.
Coz union will select only distinct data from the two tables. If you have sama data in both tables then u'll get only one row for both of those rows.
If you use union all, then this will not happen.
Hope you got it. :)
Nilanka DharmadasaPosted Nov 12, 2009, 11:29 PM
It's easy. You should change your SQL statement that you use to get the dataset from database.
select X.commoncolumn from
((select 1 as id , column_1 as commoncolumn from table_1) union (select 2 as id , column_2 as commoncolumn from table_2)) X
order by X.id
This will show the data from table 1 first and the data from table two in a single column.
Hope you can change your query with your table and column names.
If you find this usefu for u, please do not forget to mark this as accepted.
yokzuPosted Nov 12, 2009, 12:04 PM
Kirtan PatelPosted Nov 12, 2009, 10:40 AM
this can be done force fully by code but it will not make consistency as Row Column Format :)
and Also you have to Consider Cell as Header of Some Column :)