在gridview中分组 [英] grouping in gridview

查看:213
本文介绍了在gridview中分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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();

        }
    }
}



基于toc列的组gridview。怎么做?


group gridview based on toc column. how to do it?

推荐答案

你可以在SQL查询中做到这一点......



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

select duration, toc 
from processeddata_table 
where dialdate BETWEEN ?sstart and ?sstop 
Group By toc


这篇关于在gridview中分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆