Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two grids on one page, when i filter a column from first grid it get sorted properly but when i sort column from the second grid whole page get refreshed and sorting in the first grid disappears.

how do I prevent it from happening because for me both are independent grids.

i am using this for sorting...

Protected Sub GvBankBookDetails_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GvBankBookDetails.Sorting

Please help me..........

Thanks

Satej
Posted
Comments
Karthik Harve 18-Jul-12 6:53am    
Are you using same datasource for two grids? can you show your code?
satej746 18-Jul-12 7:05am    
No.
I am using different datasource for both the grids.
Protected Sub GvBankBookDetails_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GvBankBookDetails.Sorting
'' GvOurBookDetails.AllowSorting = False
''GvOurBookDetails.EnableSortingAndPagingCallbacks = False

If Session("orderbyText") = "" Or Session("orderbyText") Is Nothing Then
orderbyText = " desc"
ElseIf Session("orderbyText") = " asc" Then
orderbyText = " desc"
ElseIf Session("orderbyText") = " desc" Then
orderbyText = " asc"
End If

If e.SortExpression = "transaction_date" Or e.SortExpression = "Voucher_date" Then
sequenceOrder = "order by " & "Convert(DateTime, " & e.SortExpression & ", 105)" & orderbyText
Else
sequenceOrder = "order by " & e.SortExpression & orderbyText
End If
Session("orderbyText") = orderbyText
getRecords_TF()
getRecords_DF()

End Sub

Protected Sub GvOurBookDetails_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GvOurBookDetails.Sorting

''GvBankBookDetails.AllowSorting = False
'' GvBankBookDetails.EnableSortingAndPagingCallbacks = False

If Session("orderbyText") = "" Or Session("orderbyText") Is Nothing Then
orderbyText = " desc"
ElseIf Session("orderbyText") = " asc" Then
orderbyText = " desc"
ElseIf Session("orderbyText") = " desc" Then
orderbyText = " asc"
End If

If e.SortExpression = "transaction_date" Or e.SortExpression = "Voucher_date" Then
sequenceorderforourbook = "order by " & "Convert(DateTime, " & e.SortExpression & ", 105)" & orderbyText
Else
sequenceorderforourbook = "order by " & e.SortExpression & orderbyText
End If
Session("orderbyText") = orderbyText
getRecords_TF()
getRecords_DF()
End Sub


hi satej...

For preventing Refreshing the whole page,you need UpdatePanel for each grid, add updatepanel for two grids separately.
you try like this
first add script manager to your sourse code.

XML
<asp:ScriptManager
     ID="ScriptManager1" runat="server">
     </asp:ScriptManager>


then add update panel like this
1st grid

ASP.NET
<asp:updatepanel id="updateGrid1" runat="server" updatemode="Conditional" >
<contenttemplate>
//place your grid1 hear
 </contenttemplate>
 </asp:updatepanel>


2nd grid
ASP.NET
<asp:updatepanel id="updateGrid2" runat="server" updatemode="Conditional" >
<contenttemplate>
//place your grid2 hear
 </contenttemplate>
 </asp:updatepanel>


All the Best

Thanks&&Regards
Sandeep
 
Share this answer
 
v2
Comments
satej746 19-Jul-12 2:09am    
i am using update panel but still whole page get refreshed.

<asp:UpdatePanel ID="UpdatePanel2" runat="server" updatemode="Conditional">
<contenttemplate>
<asp:GridView runat="server" ID="GvOurBookDetails" AutoGenerateColumns="false" Width="100%"
Style="margin-left: 0px" Caption="Our Book" AllowSorting="True">
<columns>
<asp:TemplateField HeaderText="<input type='checkbox' id='chkSelect' onclick='toggleSelection(this.id)'>">
<itemtemplate>
<input type="checkbox" name="recordId" önclick="javascript:setTotalAmount('GvOurBookDetails','<%#Container.DataItemIndex%>',this.checked);"
value='<%#DataBinder.Eval(Container,"DataItem.[voucher_ledger_id]")%>' />
<input type="hidden" id="amount_<%#Container.DataItemIndex %>" value='<%#iif(eval("Debit_Amount")="0.00",eval("Credit_Amount"),eval("Debit_Amount")) %>' />

<HeaderStyle HorizontalAlign="Left" CssClass="Freezing"></HeaderStyle>

<asp:TemplateField HeaderText="Voucher No." SortExpression="generated_voucher_No"
ControlStyle-CssClass="commonGridHeader " ControlStyle-Width="20">
<itemtemplate>

<%#DataBinder.Eval(Container.DataItem, "generated_voucher_No")%>



<asp:BoundField HeaderText="Date" DataField="Voucher_date" SortExpression="cheque_date" />
<asp:BoundField HeaderText="Cheque No." DataField="cheque_no" SortExpression="cheque_no" />
<asp:BoundField HeaderText="Debit Amt." DataField="Debit_Amount" SortExpression="Debit_Amount" />
<asp:BoundField HeaderText="Credit Amt." DataField="Credit_Amount" SortExpression="Credit_Amount" />
<asp:BoundField HeaderText="Ledger Narration" DataField="Narration" SortExpression="Narration"
ControlStyle-Width="32" />
<asp:BoundField HeaderText="Party Name" DataField="party_name" SortExpression="party_name"
ControlStyle-Width="15" />
<asp:BoundField HeaderText="Slip No." DataField="pay_slip_no" SortExpression="pay_slip_no" />
<asp:BoundField HeaderText="S" DataField="voucher_status" SortExpression="voucher_status"
ControlStyle-Width="4" />
<asp:TemplateField HeaderText="">
<itemtemplate>
<input type="hidden" id='hf_amt_type_ourbook
sandeep nagabhairava 19-Jul-12 2:15am    
where is "contenttemplate:?
basurajkumbhar 28-Jul-12 6:16am    
I have displayed 8 images when i have click the below of the [pre 1 2 3 next] then this images box have new/next images display. Yet i am not use the datagrid view.
SQL
if you have sorting enabled in your GridView, that will also cause a postback, which you can "hide" by adding AJAX to your page.

A simple (not the most efficient) way to do this will be to add a ScriptManager control to your page to enable AJAX controls in it, then add an UpdatePanel control and move your GridView inside this UpdatePanel. This will make the PostBacks "invisible".
 
Share this answer
 
Comments
basurajkumbhar 28-Jul-12 6:16am    
I have displayed 8 images when i have click the below of the [pre 1 2 3 next] then this images box have display new/next images. I am not use the datagrid view.
I have displayed 8 images when i have click the below of the [pre 1 2 3 next] then this images box have new/next images display. Yet i am not use the datagrid view.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900