第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

Linq學(xué)習(xí)筆記:分頁(yè)功能

標(biāo)簽:
C#

下面的代码演示了如何利用Linq结合AspNetPager控件实现分页功能,以及如果利用Linq to Xml将当前页数据保存为Xml

 using (NorthWindDataContext db = new NorthWindDataContext())
            {               
                int Page = Utils.GetPageIndex();//取得当前页码
                var s = from c in db.T_Tests orderby c.F_AutoId select new { c.F_ID,F_AutoID = c.F_AutoId.ToString().PadLeft(8,'0')};                             
var p = s.Skip((Page - 1) * this.AspNetPager1.PageSize).Take(this.AspNetPager1.PageSize);//取得当前页数据(注:先跳过(Page-1)*PageSize条记录后,再取PageSize条记录)
                this.GridView3.DataSource = p; 
                this.GridView3.DataBind();

                this.AspNetPager1.RecordCount = s.Count();//设置分页控件的总记录数
                this.AspNetPager1.CurrentPageIndex = Page;//设置分页控件的当前页


                //将当前数据保存为xml
                XDocument doc = new XDocument(new XElement(
                                                            "T_Test", from d in p                                                         
                                                                        select 
                                                                        (
                                                                            new XElement
                                                                            (
                                                                                "data",
                                                                                new XAttribute("F_ID", d.F_ID),
                                                                                new XAttribute("F_AutoID", d.F_AutoID)
                                                                            )
                                                                        )
                                                           )
                                               );
                doc.Save("c:\\demo.xml"); 

                db.Dispose();//及时释放资源
            }

保存的Demo.Xml内容如下:

<?xml version="1.0" encoding="utf-8"?>
<T_Test>
  <data F_ID="9552e4dc-9a0a-414e-ab80-b0252f88411e" F_AutoID="00000014" />
  <data F_ID="2d135009-d24f-46ca-92ba-6d7b706f4025" F_AutoID="00000015" />
  <data F_ID="2e725756-da8c-4ede-ba13-00aa91fbd8e2" F_AutoID="00000016" />
  <data F_ID="d6a1b0aa-40e8-4cf8-a3f2-c1c28576d6f3" F_AutoID="00000017" />
  <data F_ID="fed11493-6349-419e-a83b-c42f6d318735" F_AutoID="00000018" />
  <data F_ID="c1eedd2b-2d92-46e3-8aab-f4180e106c6f" F_AutoID="00000019" />
  <data F_ID="762a57b5-8ca6-4d8c-9569-bbd62d4873a6" F_AutoID="00000020" />
  <data F_ID="a468b3b0-1392-4bf5-be84-b2e1a90c53de" F_AutoID="00000021" />
  <data F_ID="d3526eff-23d4-41a4-b6b2-d4b1f5bf6085" F_AutoID="00000022" />
  <data F_ID="6e0687ea-07be-4a83-a50f-4d3700868d15" F_AutoID="00000023" />
  <data F_ID="f343f96f-8d2b-4ef5-a431-82df7f607d6e" F_AutoID="00000024" />
  <data F_ID="34d7d945-599c-4986-bdec-2ee7bf338e0f" F_AutoID="00000025" />
  <data F_ID="2c569843-ecfd-4f53-a59b-5e28083ed4e3" F_AutoID="00000026" />
</T_Test>

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消