views:

201

answers:

2

I want to taking paging off of my gridview. I am doing this in javascript by redirecting. I'll explain below. But i would rather take off paging and have just my Gridview reload in the update panel. 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?

+1  A: 

Here is the javasscript which is used to turnOff the paging of the grid view control

  // 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.

Asim Sajjad
it does. but i want the data from the other pages to go down the page.
Eric
A: 

Add some buttons inside the UpdatePanel that do this:

GridView1.AllowPaging = False
GridView1.DataBind()

GridView1.AllowPaging = True
GridView1.DataBind()
BenB