Click here to Skip to main content
15,897,334 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900