Results 1 to 7 of 7

Thread: persist gridview data

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    persist gridview data

    Hi how can i persist gridview data after crosspage posting? It seems that every time i visit another page and get back to page the entire gridview data and page index were reset.

  2. #2
    Fanatic Member
    Join Date
    Dec 2009
    Posts
    904

    Re: persist gridview data

    are you binding the gridview with data in the page load event?

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: persist gridview data

    jlbantang,

    When you say visit another page and get back to page, how exactly are you handling this navigation? Through code, or through the user using the back button in their browser?

    I think you are going to need to show us some of the code that you are using before we will be able to help you.

    Gary

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    Re: persist gridview data

    hey,

    The purpose of gridview will allow user to filter data. For each filtered row a hyperlinked button is added which in turn use by user to navigate to other page.

    vb Code:
    1. <div>
    2.         <img src="Images/logo1.gif" />&nbsp;<br />
    3.         <br />
    4.         <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="~/requisition.aspx">Requisition</asp:HyperLink>
    5.         <asp:HyperLink ID="HyperLink5" runat="server" NavigateUrl="~/requestworkflow.aspx">Request Workflow</asp:HyperLink>
    6.         <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/new_delivery.aspx">New Delivery</asp:HyperLink>
    7.         <asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="~/stockcard.aspx">Stock Card</asp:HyperLink>
    8.         <asp:HyperLink ID="HyperLink3" runat="server" NavigateUrl="~/contactus.aspx">Contact Us</asp:HyperLink><br />
    9.     <asp:GridView ID="GridView1" runat="server"
    10.               AutoGenerateColumns="False"
    11.               DataSourceID="SqlDataSource1" AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None">
    12. <Columns>
    13. <asp:HyperLinkField DataNavigateUrlFields="ID,pk_ddlvryNO,lpono" DataNavigateUrlFormatString="edit_delivery.aspx?id={0}"
    14.     Text="&lt;img src='Images/edit.gif' alt='Edit' border='0'/&gt;" />
    15.  
    16. <asp:BoundField DataField="pk_ddlvryNO" HeaderText="Delivery No"
    17.                 SortExpression="pk_ddlvryNO" />
    18. <asp:BoundField DataField="entereddate" HeaderText="Dated"
    19.                 SortExpression="entereddate" />
    20. <asp:BoundField DataField="pk_RFGNO" HeaderText="Requisition No"
    21.                 SortExpression="pk_RFGNO" />
    22.                                                
    23. <asp:BoundField DataField="lpono" HeaderText="LPO No"            
    24.                 SortExpression="lpono" />
    25.                
    26. <asp:BoundField DataField="lpodate" HeaderText="Dated"            
    27.                 SortExpression="lpodate" />
    28.              
    29.  <asp:BoundField DataField="supplier" HeaderText="Supplier"            
    30.                 SortExpression="suplier" />              
    31.                
    32. <asp:BoundField DataField="invno" HeaderText="Invoice No"            
    33.                 SortExpression="invno" />
    34.  
    35. <asp:BoundField DataField="invdate" HeaderText="Dated"            
    36.                 SortExpression="invdate" />
    37.                
    38. </Columns>
    39.         <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    40.         <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    41.         <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
    42.         <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    43.         <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    44.         <EditRowStyle BackColor="#999999" />
    45.         <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    46. </asp:GridView>
    47.         <asp:DropDownList ID="criteriaDropDownList" runat="server">
    48.             <asp:ListItem>ALL</asp:ListItem>
    49.             <asp:ListItem>Delivery No</asp:ListItem>
    50.             <asp:ListItem>Requisition No</asp:ListItem>
    51.             <asp:ListItem>LPO No</asp:ListItem>
    52.             <asp:ListItem>Invoice No</asp:ListItem>
    53.             <asp:ListItem>Supplier</asp:ListItem>
    54.         </asp:DropDownList>
    55.         <asp:TextBox ID="valueTextBox" runat="server"></asp:TextBox>
    56.         <asp:Button ID="Button1" runat="server" Text="Button" />
    57.         <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/img/edit.gif" /><br />
    58.         Theme Color<br />
    59.         <img src="Images/search_bg.gif" /><br />
    60.         <br />
    61.         |
    62.         <br />
    63.         <br />
    64.     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:direct_deliveryConnectionString %>"
    65.             SelectCommand="Select pk_ddlvryMasterID as ID ,pk_ddlvryNO , convert(varchar,entereddate,106) as entereddate ,pk_rfgNO,lpono, convert(varchar,lpodate,106) as lpodate,Supplier,invno,  convert(varchar,invdate,106)  as invdate from qDDlvryMaster">
    66.         </asp:SqlDataSource>
    67.     </div>

    vb Code:
    1. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim filter As String = "Select pk_ddlvryMasterID as ID ,pk_ddlvryNO "
    3.         filter += ", convert(varchar,entereddate,106) as entereddate"
    4.         filter += ",pk_rfgno,lpono, convert(varchar,lpodate,106) as lpodate"
    5.         filter += ",Supplier,invno,  convert(varchar,invdate,106)  as invdate"
    6.         filter += " from qDDlvryMaster "
    7.  
    8.         Dim criteria As String = String.Empty
    9.  
    10.         Select Case criteriaDropDownList.Text.ToUpper
    11.             Case "DELIVERY NO" : criteria = "pk_ddlvryNO"
    12.             Case "REQUISITION NO" : criteria = "pk_rfgno"
    13.             Case "LPO NO" : criteria = "lpono"
    14.             Case "INVOICE NO" : criteria = "invno"
    15.             Case "SUPPLIER" : criteria = "supplier"
    16.  
    17.         End Select
    18.  
    19.         'TODO add cost centre id
    20.         If criteriaDropDownList.Text <> "ALL" Then
    21.             SqlDataSource1.SelectCommand = filter & " WHERE " & criteria & "  like '%" & valueTextBox.Text & "%' ORDER BY pk_ddlvryMasterID DESC"
    22.         Else
    23.             SqlDataSource1.SelectCommand = filter & " ORDER BY pk_ddlvryMasterID DESC"
    24.         End If
    25.         GridView1.DataBind()
    26.  
    27.     End Sub
    28.  
    29.     Protected Sub OnPaging(ByVal sender As Object, ByVal e As GridViewPageEventArgs) Handles GridView1.PageIndexChanging
    30.         GridView1.PageIndex = e.NewPageIndex
    31.         GridView1.DataBind()
    32.     End Sub

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: persist gridview data

    But you still haven't explained how it is that they get back to the filtered GridView?

    It might be the case that you need to store the "filter" in a Session Variable, and use this "filter" value to setup the GridView once a users navigates back to the same page.

    Gary

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2007
    Posts
    617

    Re: persist gridview data

    Quote Originally Posted by gep13 View Post
    But you still haven't explained how it is that they get back to the filtered GridView?

    It might be the case that you need to store the "filter" in a Session Variable, and use this "filter" value to setup the GridView once a users navigates back to the same page.

    Gary
    A hyperlink button is provided on the details page to get back to the filtering page.

    I believed session variable will work in this case.

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: persist gridview data

    So are you dynamically setting the NavigateUrl property of the Hyperlink, or is this fixed? Another way would be to provide a QueryString parameter on the Hyperlink button, that is then read in on the other page to provide the "filter" for the GridView.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width