Click here to Skip to main content
13,057,050 members (43,186 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 0: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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170728.6 | Last Updated 13 Jul 2010
Copyright © CodeProject, 1999-2017
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