Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
using System.Data;

namespace grisviewgrouping
{
    public partial class _Default : System.Web.UI.Page
    {
        MySqlConnection con = new MySqlConnection("Server=localhost;Database=projecttt;Uid=root;Pwd=xxxxxx;");

        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            con.Open();
            MySqlCommand com = new MySqlCommand("select duration, toc from processeddata_table where dialdate BETWEEN ?sstart and ?sstop ", con);
            com.Parameters.Add("?sstart", MySqlDbType.Datetime).Value = TextBox1.Text;
            com.Parameters.Add("?sstop", MySqlDbType.Datetime).Value = TextBox2.Text;
            MySqlDataAdapter da = new MySqlDataAdapter(com);
            DataSet ds = new DataSet();
            da.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
            con.Close();

        }
    }
}

group gridview based on toc column. how to do it?
Posted
Updated 2-Apr-13 23:42pm
v2

1 solution

You Can do it in your SQL query itself ...

SQL
select duration, toc 
from processeddata_table 
where dialdate BETWEEN ?sstart and ?sstop 
Group By toc
 
Share this answer
 
Comments
navin ks 3-Apr-13 5:50am    
if i use groupby i will get one row for each toc. i need all rows.
navin ks 3-Apr-13 5:51am    
i have multiple rows for each toc name
Naveen.Sanagasetti 3-Apr-13 5:56am    
send me sample data

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