Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hi...
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
Gridview.datasource=ds;
Gridview.Databind();
My gridview format is:
Users Outcome1 Outcome2 Outcome3
User1
User2
User3
(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);
adpout.Fill(dsout);
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"])));
}

ds.Tables.Add(dtble);
 
string strUser = "Select UserName from User_Mast group by UserName";
DataSet dsUser = new DataSet();
SqlDataAdapter adpUser = new SqlDataAdapter(strUser, conn);
adpUser.Fill(dsUser);

foreach (DataRow drUser in dsUser.Tables[0].Rows)
{
DataRow drow = ds.Tables[0].NewRow();
drow["Users"]=Convert.ToString(drUser["UserName"]);
ds.Tables[0].Rows.Add(drow);

}
 

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
good
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.
  Permalink  

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.1411022.1 | Last Updated 13 Jul 2010
Copyright © CodeProject, 1999-2014
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