主頁 > 知識(shí)庫 > gridview+objectdatasource+aspnetpager整合實(shí)例

gridview+objectdatasource+aspnetpager整合實(shí)例

熱門標(biāo)簽:泰州手機(jī)外呼系統(tǒng)軟件 濟(jì)源人工智能電話機(jī)器人價(jià)格 地圖標(biāo)注位置多的錢 內(nèi)蒙古智能電銷機(jī)器人哪家強(qiáng) 杭州智能電話機(jī)器人 廈門四川外呼系統(tǒng) 山東防封電銷卡辦理套餐 怎樣在地圖標(biāo)注消火栓圖形 百度地圖標(biāo)注點(diǎn)擊事件

前臺(tái)代碼:

復(fù)制代碼 代碼如下:

asp:GridView ID="viewIShow" runat="server" DataSourceID="ObjectDataSource1"
                    AllowPaging="True" AutoGenerateColumns="False"
                    OnRowCommand="viewIShow_RowCommand" PageSize="2"
                    OnPageIndexChanging="viewIShow_PageIndexChanging"
                    OnDataBound="viewIShow_DataBound">

                    Columns>
                        asp:BoundField DataField="title" HeaderText="名稱" />
                        asp:BoundField DataField="clicknum" HeaderText="播放次數(shù)" />
                        asp:BoundField DataField="addtime" HeaderText="更新日期" />
                        asp:TemplateField HeaderText="操作">
                            ItemTemplate>
                                asp:LinkButton ID="LinkButton1" runat="server" CommandName="up" CommandArgument='%#Eval("id") %>'>晉級(jí)/asp:LinkButton>asp:LinkButton
                                    ID="LinkButton2" runat="server" CommandName="down" CommandArgument='%#Eval("id") %>'>降級(jí)/asp:LinkButton>
                            /ItemTemplate>

                        /asp:TemplateField>
                    /Columns>
                    PagerTemplate>
                        table border="0" cellpadding="0" cellspacing="1" style="width: 100%; height: 100%;">
                            tr style="height: 28px; padding-left: 20px;">
                                td class="pages">
                                    webdiyer:AspNetPager ID="myPage" runat="server"
                                        OnPageChanged="myPage_PageChanged" >/webdiyer:AspNetPager>
                                /td>
                            /tr>
                        /table>
                    /PagerTemplate>
                /asp:GridView>
                asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
                    DataObjectTypeName="AUDIOSYSTEM.Model.ishow" DeleteMethod="Delete"
                    InsertMethod="Add" SelectMethod="GetList" TypeName="AUDIOSYSTEM.BLL.ishow"
                    UpdateMethod="Update" OnSelected="ObjectDataSource1_Selected">
                    SelectParameters>
                        asp:Parameter Name="type" Type="String" DefaultValue="week" />
                        asp:ControlParameter ControlID="txtStartTime"
                            DefaultValue="2000/01/01 00:00:00" Name="start"
                            PropertyName="Text" Type="DateTime" />
                        asp:ControlParameter ControlID="txtEndTime" Name="end" PropertyName="Text"
                            Type="DateTime" DefaultValue="2500/01/01 00:00:00" />
                    /SelectParameters>
                    DeleteParameters>
                        asp:Parameter Name="videoId" Type="Int32" />
                        asp:Parameter Name="type" Type="String" DefaultValue="week" />
                    /DeleteParameters>
                /asp:ObjectDataSource>


后臺(tái)代碼:

復(fù)制代碼 代碼如下:

protected void myPage_PageChanged(object sender, EventArgs e)
         {
             GridViewRow pagerRow = viewIShow.BottomPagerRow;
             AspNetPager myPage = (AspNetPager)pagerRow.Cells[0].FindControl("myPage");
             viewIShow.PageIndex = myPage.CurrentPageIndex - 1;
         }

         protected void viewIShow_DataBound(object sender, EventArgs e)
         {
             GridViewRow pagerRow = viewIShow.BottomPagerRow;
             AspNetPager myPage = (AspNetPager)pagerRow.Cells[0].FindControl("myPage");

             GridView view = (GridView)sender;
             myPage.PageSize = view.PageSize;
             myPage.CurrentPageIndex = view.PageIndex +1; //GridView分頁索引是從0開始,AspNetPager是從1開始的
         }

         protected void ObjectDataSource1_Selected(object sender, ObjectDataSourceStatusEventArgs e)
         {
             DataSet ds = (DataSet)e.ReturnValue; //ObjectDataSource查詢方法返回什么類型就轉(zhuǎn)成什么類型

             GridViewRow pagerRow = viewIShow.BottomPagerRow;
             AspNetPager myPage = (AspNetPager)pagerRow.Cells[0].FindControl("myPage");

             if (ds == null)
             {
                 myPage.RecordCount = 0;
             }
             else
             {
                 myPage.RecordCount = ds.Tables[0].Rows.Count;
             }
         }

您可能感興趣的文章:
  • asp.net 使用ObjectDataSource控件在ASP.NET中實(shí)現(xiàn)Ajax真分頁
  • 動(dòng)態(tài)指定任意類型的ObjectDataSource對(duì)象的查詢參數(shù)
  • ASP.NET中 ObjectDataSource控件的DataObjectTypeName屬性
  • 在ASP.NET 2.0中操作數(shù)據(jù)之一:創(chuàng)建一個(gè)數(shù)據(jù)訪問層
  • 在ASP.NET 2.0中操作數(shù)據(jù)之二:創(chuàng)建一個(gè)業(yè)務(wù)邏輯層
  • 在ASP.NET 2.0中操作數(shù)據(jù)之三:創(chuàng)建母版頁和站點(diǎn)導(dǎo)航
  • 在ASP.NET 2.0中操作數(shù)據(jù)之四:使用ObjectDataSource展現(xiàn)數(shù)據(jù)
  • 在ASP.NET 2.0中操作數(shù)據(jù)之五:聲明參數(shù)
  • 在ASP.NET 2.0中操作數(shù)據(jù)之六:編程設(shè)置ObjectDataSource的參數(shù)值

標(biāo)簽:周口 洛陽 朝陽 喀什 臺(tái)州 朔州 百色 新鄉(xiāng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《gridview+objectdatasource+aspnetpager整合實(shí)例》,本文關(guān)鍵詞  gridview+objectdatasource+aspnetpager,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《gridview+objectdatasource+aspnetpager整合實(shí)例》相關(guān)的同類信息!
  • 本頁收集關(guān)于gridview+objectdatasource+aspnetpager整合實(shí)例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章