COLUMN WISE DISPLAYING TWO QUERIE VALUE FROM DATASET TO GRIDVIEW
-
hai, currently i m using vb.net 2005 (framework 2.0) and sql server 2000. here i have two query where i bind those values to gridview. i need the values in column wise. for example... sql1=select studentname from tab_student sql2=select employeename from tab_employee The result of the above queries should be combined in a single gridview COLUMN WISE (note : no relationship between two tables) waiting for the reply - KARAN
-
hai, currently i m using vb.net 2005 (framework 2.0) and sql server 2000. here i have two query where i bind those values to gridview. i need the values in column wise. for example... sql1=select studentname from tab_student sql2=select employeename from tab_employee The result of the above queries should be combined in a single gridview COLUMN WISE (note : no relationship between two tables) waiting for the reply - KARAN
Hi karan, I dont know why you want to show it like that, but you can loop through two tables, i mean having two loops one inside the other (Note: Outer for loop should be for max row count table) and add the data in to a new table. Then bind the new table to the grid. I have not implemented this, but i am sure this should work. Try. Cheers, Sudhanva.
-
hai, currently i m using vb.net 2005 (framework 2.0) and sql server 2000. here i have two query where i bind those values to gridview. i need the values in column wise. for example... sql1=select studentname from tab_student sql2=select employeename from tab_employee The result of the above queries should be combined in a single gridview COLUMN WISE (note : no relationship between two tables) waiting for the reply - KARAN
Why not use a union?
select studentname as [Name] from tab_student
union all
select employeename as [Name] from tab_employeethen you only have 1 lot of data to bind, and you can put an order by on the query too.
Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP
-
Why not use a union?
select studentname as [Name] from tab_student
union all
select employeename as [Name] from tab_employeethen you only have 1 lot of data to bind, and you can put an order by on the query too.
Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP
Hey Bob, Congrats
cheers, Abhijit CodeProject.Com MVP
-
hai, currently i m using vb.net 2005 (framework 2.0) and sql server 2000. here i have two query where i bind those values to gridview. i need the values in column wise. for example... sql1=select studentname from tab_student sql2=select employeename from tab_employee The result of the above queries should be combined in a single gridview COLUMN WISE (note : no relationship between two tables) waiting for the reply - KARAN
You could combine your results in SQL. or You could add a template column to your gridview and set the values in the OnRowDatabound.
I didn't get any requirements for the signature
-
Hey Bob, Congrats
cheers, Abhijit CodeProject.Com MVP
-
Why not use a union?
select studentname as [Name] from tab_student
union all
select employeename as [Name] from tab_employeethen you only have 1 lot of data to bind, and you can put an order by on the query too.
Bob Ashfield Consultants Ltd Proud to be a 2009 Code Project MVP
-
You could combine your results in SQL. or You could add a template column to your gridview and set the values in the OnRowDatabound.
I didn't get any requirements for the signature
DataTable dt1 = new DataTable("student"); dt1.Columns.Add("Name", typeof(string)); dt1.Rows.Add("a"); dt1.Rows.Add("b"); dt1.Rows.Add("c"); DataTable dt2 = new DataTable("employee"); dt2.Columns.Add("Name", typeof(string)); dt2.Rows.Add("x"); dt2.Rows.Add("y"); dt2.Rows.Add("z"); DataTable dt3 = new DataTable("student\_employee"); dt3.Columns.Add("StudentName", typeof(string)); dt3.Columns.Add("EmployeeName", typeof(string)); //further you can add an IF condition to check the max dt.row.count here for (int i = 0; i < dt1.Rows.Count; i++ ) { for (int j = 0; j < dt2.Rows.Count; j++) { dt3.Rows.Add(dt1.Rows\[i\]\["Name"\].ToString(), dt2.Rows\[i\]\["Name"\].ToString()); break; } } //bind the dt3 with gridview here
Cheers, Sudhanva