【问题标题】:How can i select data with linq part by part of rows?如何使用 linq 逐行选择数据?
【发布时间】:2010-06-21 09:11:21
【问题描述】:

我想从数据表或 sql 表中选择数据,或按 50 行列出 50 行。例如:

var list = from x in dtable select x ----->前 50 行单击 GridView 下一个 50 行的下一步按钮。超过 50 行点击下一步按钮来监控 GridView?

例如数据:



        static DataTable GetTable()
        {
            //
            // Here we create a DataTable with four columns.
            //
            DataTable table = new DataTable();
            table.Columns.Add("Dosage", typeof(int));
            table.Columns.Add("Drug", typeof(string));
            table.Columns.Add("Patient", typeof(string));
            table.Columns.Add("Date", typeof(DateTime));

            //
            // Here we add five DataRows.
            //
            table.Rows.Add(25, "Indocin", "David", DateTime.Now);
            table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
            table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
            table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
            table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);

            return table;
        }
    }

【问题讨论】:

    标签: c# .net visual-studio visual-studio-2008 linq


    【解决方案1】:

    基本上,您可以根据需要使用 .Take() 和 .Skip() 方法。

    Ref 1

    Ref 2

    Ref 3

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-16
      • 1970-01-01
      • 2018-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-18
      相关资源
      最近更新 更多