• gridview 绑定多个格式相同的数据源(数据查询合并)


    在做项目时,要求在同一个GridView中同时显示不同分组中的前若干条数据

    几个技术要点:

    1、数据分组,本方法中未用group by

    2、几个结果格式相同的查询合并绑定

    3、取查询结果的前或后若干条数据

            public int BindLiftData()

            {

                int count = 0;

                using (MySqlConnection conn = new MySqlConnection(dbServer))

                {

                    FrDData db = new FrDData(conn);

                    List<int> ids = new List<int>();

                    var item =  from i in db.Items

                                join p in db.ProgS on i.ProgID equals p.ID

                                where p.State == 1 && i.Type == "升程"

                                select new {i.ID};

                    bool isFirst = true;

                    int firstID =0;

                    foreach (var i in item)

                    {

                        if (isFirst)

                        {

                            firstID = i.ID;

                            isFirst = false;

                        }

                        else

                            ids.Add(i.ID);

                    }

                    var q = (from i in db.Items

                             join l in db.Lifts on i.ID equals l.ItemID

                             where i.ID == firstID

                             orderby l.ID descending

                             select new { i.ID, i.Name, l.Angle, i.Stole, l.Lift }).Take(3).ToList();

                    foreach(var x in ids)

                    {

                        var r = (from i in db.Items

                                 join l in db.Lifts on i.ID equals l.ItemID

                                 where i.ID == x

                                 orderby l.ID descending

                                 select new { i.ID, i.Name, l.Angle, i.Stole, l.Lift }).Take(3).ToList();

                        q.AddRange(r);

                    }

                    gvLift.DataSource = q;

                    count = q.Count;         

                }

                return count;

            }

  • 相关阅读:
    veil-evasion免杀处理
    对程序"加料"
    堆栈溢出
    ICMP隧道 ptunnle
    socat流量操控
    DNS隧道 iodns
    dns隧道 dns2tcpd
    ssh X协议转发
    ssh动态端口转发
    ssh远程端口转发
  • 原文地址:https://www.cnblogs.com/xihong2014/p/4227658.html
Copyright © 2020-2023  润新知