简体   繁体   English

关闭分页的更简单方法

[英]Easier way to turn off paging

I want to taking paging off of my gridview. 我想取消我的gridview的分页。 I am doing this in javascript by redirecting. 我通过重定向在javascript中执行此操作。 I'll explain below. 我会在下面解释。 But i would rather take off paging and have just my Gridview reload in the update panel. 但是我宁愿取消分页,只在更新面板中重新加载Gridview。 How can that be done? 那怎么办?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If Request.Params("R") = "1" Then
        GridView1.AllowPaging = False
    End If
End Sub


function Paging(remove) {
    var txt = $get('<%=TextBox1.ClientID%>');
    var query = window.location.search.substring(1);
    //alert (query);
    window.location = url + 'R=' + remove ;
    txt.value = txt.value;
}

Dim bttnrempag As New Button
    bttnrempag.ID = "bttnrempag"
    bttnrempag.Text = "      Paging"
    bttnrempag.CssClass = "bttnMinEG"
    bttnrempag.ValidationGroup = "alone"
    bttnrempag.Attributes.Add("onclick", "Paging('1')")

    Dim bttnallowpag As New Button
    bttnallowpag.ID = "bttnallowpag"
    bttnallowpag.Text = "      Paging"
    bttnallowpag.ValidationGroup = "alone"
    bttnallowpag.CssClass = "bttnAddEG"
    bttnallowpag.Attributes.Add("onclick", "Paging('0')")
//this is where i add the buttons to my Gridview
    cell.Controls.Add(bttnrempag) '36
    cell.Controls.Add(bttnallowpag)



<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate >
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
            AutoGenerateColumns="False" BackColor="White" BorderColor="#E7E7FF" 
            BorderStyle="None" BorderWidth="1px" CellPadding="3" 
            DataSourceID="SqlDataSource1" Font-Names="Comic Sans MS" Font-Size="XX-Small"

            Font-Bold="True" PageSize="15" >
            <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />

            <Columns>
                <asp:BoundField DataField="scan" HeaderText="Scan" SortExpression="scan" />
                <asp:BoundField DataField="ScanType" HeaderText="ScanType" ReadOnly="True" 
                    SortExpression="ScanType" />
                <asp:TemplateField HeaderText="Item Desc."></asp:TemplateField>
                <asp:BoundField />
                <asp:BoundField />
                <asp:BoundField />
                <asp:BoundField />
                <asp:BoundField  />
                <asp:BoundField  />
                <asp:BoundField  />
            </Columns>
            <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
            <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
            <EmptyDataTemplate>
            <head>
                <meta http-equiv="refresh" content="5;URL=/Corporate_newpo/ReceivingLog.aspx?">
            </head>
                <script type="text/javascript" >
                    var count = 6;
                    var counter = setInterval("timer()", 1000); //1000 will  run it every 1 second

                    function timer() {
                        count = count - 1;
                        if (count <= 0) {
                            clearInterval(counter);
                            //counter ended, do something here
                            return;
                        }
                        $get("timer").innerHTML = "The Table will Reload in " + count + " secs";
                    }
                </script>
                <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Large" 
                    ForeColor="#993333" Text="No Data was Found for the Selected Filter"></asp:Label><br /><br />
               <span id="timer" style="font-size:medium;color:blue"></span>
            </EmptyDataTemplate>
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
            <AlternatingRowStyle BackColor="#F7F7F7" />

            </asp:GridView>
        </ContentTemplate> 
    </asp:UpdatePanel>

And of course I have data in the Grid. 当然,我在网格中有数据。 I'm just not showing it here. 我只是不在这里显示。 How can I turn paging off without having to redirect with a variable as i'm doing here with R in javascript? 我如何在不使用变量重定向的情况下关闭分页,就像我在JavaScript中使用R一样?

Here is the javasscript which is used to turnOff the paging of the grid view control 这是用于关闭网格视图控件分页的Javasscript

  // get datagrid by rendered table name
  var myGridView = document.getElementById('<%= grdvCategoryList.ClientID % >');

   var intNumberOfRows = myGridView.rows.length;
   myGridView.rows[intNumberOfRows-1].style.visibility='hidden';
   myGridView.rows[intNumberOfRows-1].style.display='none';
   return false;

This will hide the last row of the grid view control. 这将隐藏网格视图控件的最后一行。 Hope that will help you. 希望对您有所帮助。

Add some buttons inside the UpdatePanel that do this: 在UpdatePanel内添加一些可实现此目的的按钮:

GridView1.AllowPaging = False
GridView1.DataBind()

GridView1.AllowPaging = True
GridView1.DataBind()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM