Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET
I am using ASP.NET with C#.
I am having Gridview in .aspx page and i want to bind gridview to dataset.
Iam binding Gridview to dataset through
My gridview format is:
Users Outcome1 Outcome2 Outcome3
(for all Outcome from Outcome table and Users from User Table.)
I am using:
string strOutcome = "Select Distinct Name from Outcome as exp group By Name";
DataSet dsout = new DataSet();
SqlDataAdapter adpout = new SqlDataAdapter(strOutcome, conn);
DataSet ds = new DataSet();
DataTable dtble = new DataTable("tmp");
dtble.Columns.Add(new DataColumn("Users", typeof(string)));

foreach (DataRow drout in dsout.Tables[0].Rows)
dtble.Columns.Add(new DataColumn(Convert.ToString(drout["Name"])));

string strUser = "Select UserName from User_Mast group by UserName";
DataSet dsUser = new DataSet();
SqlDataAdapter adpUser = new SqlDataAdapter(strUser, conn);

foreach (DataRow drUser in dsUser.Tables[0].Rows)
DataRow drow = ds.Tables[0].NewRow();


By this i am getting above format in gridview.
But now i have to retieve data from database table Enquiry having both fields User and Outcome.
i want to retrieve total count for particular user against their outcome.
how to do that??
Posted 13-Jul-10 1:18am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Why on earth are you not getting back a dataset in the format you want ? Surely this code is not all in your code behind for the aspx ?
You retrieve a total count with the select count statement in SQL.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web01 | 2.8.150326.1 | Last Updated 13 Jul 2010
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100