Click here to Skip to main content
15,896,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There are two grids in my page . i am sorting one grid by gridview_sorting event it refreshes whole page even if i used update panel.

My grids are placed in the update panel but still whole page get refreshed(i have used scriptmanager ).

please help me out ..............

below is my aspx code....


XML
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

                                    <ContentTemplate>
                                        <asp:GridView runat="server" ID="GvBankBookDetails" AutoGenerateColumns="False" Width="100%"
                                            Style="margin-left: 0px; vertical-align: top" Caption="Bank Statement" AllowSorting="True" EnableSortingAndPagingCallbacks = "true">
                                            <Columns>
                                                <%--<asp:TemplateField HeaderStyle-HorizontalAlign="Left">--%>
                                                <%--  aaliya 27092010 --%>
                                                <asp:TemplateField HeaderText="&lt;input type='checkbox' id='rdoSelect' onclick='toggle_OnSelection(this.id)'&gt;">
                                                    <ItemTemplate>
                                                        <input type="checkbox" name="bankBookId" onclick="javascript:setTotalAmount('GvBankBookDetails','<%#Container.DataItemIndex%>',this.checked);"
                                                            value='<%#DataBinder.Eval(Container,"DataItem.[bank_book_id]")%>' />
                                                        <input type="hidden" id="balanceAmt_<%#Container.DataItemIndex %>" value="<%#eval("balance_amt") %>" />
                                                        <%-- aaliya 27092010 --%>
                                                        <!--value="'<%#eval("bank_book_id") %>'"-->
                                                    </ItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Left" CssClass="Freezing"></HeaderStyle>
                                                </asp:TemplateField>
                                                <asp:BoundField HeaderText="Date" DataField="transaction_date" SortExpression="transaction_date" />
                                                <asp:BoundField HeaderText="Reference No." DataField="reference_no" SortExpression="reference_no" />
                                                <asp:BoundField HeaderText="Narration" DataField="narration" SortExpression="narration"
                                                    ControlStyle-Width="25" />
                                                <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="Balance Amt." DataField="balance_amt" SortExpression="balance_amt" />
                                                --%>
                                                <asp:BoundField HeaderText="S" DataField="voucher_status" SortExpression="voucher_status"
                                                    ControlStyle-Width="4" />
                                                <asp:TemplateField HeaderText="">
                                                    <ItemTemplate>
                                                        <input type="hidden" id='hf_amt_type_bankbook' name='hf_amt_type_bankbook' value='<%#DataBinder.Eval(Container,"DataItem.[amt_type]")%>' />
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>
                                            <FooterStyle Font-Bold="True" ForeColor="White" />
                                            <RowStyle CssClass="label" />
                                            <EditRowStyle />
                                            <SelectedRowStyle Font-Bold="True" />
                                            <PagerStyle ForeColor="White" HorizontalAlign="Center" />
                                            <HeaderStyle CssClass="Freezing" Font-Bold="True" />
                                            <AlternatingRowStyle BackColor="White" />
                                        </asp:GridView>
                                        </ContentTemplate>
                                        <Triggers><asp:AsyncPostBackTrigger ControlID="GvBankBookDetails" EventName="Sorting" /></Triggers>
                                       </asp:UpdatePanel>

<pre lang="xml">&lt;asp:UpdatePanel ID=&quot;UpdatePanel2&quot; runat=&quot;server&quot; UpdateMode=&quot;Conditional&quot;&gt;

                                    &lt;ContentTemplate&gt;
                                        &lt;asp:GridView runat=&quot;server&quot; ID=&quot;GvOurBookDetails&quot; AutoGenerateColumns=&quot;false&quot; Width=&quot;100%&quot;
                                            Style=&quot;margin-left: 0px&quot; Caption=&quot;Our Book&quot; AllowSorting=&quot;True&quot; EnableSortingAndPagingCallbacks=&quot;true&quot;&gt;
                                            &lt;Columns&gt;
                                                &lt;asp:TemplateField HeaderText=&quot;&amp;lt;input type=&#39;checkbox&#39; id=&#39;chkSelect&#39; onclick=&#39;toggleSelection(this.id)&#39;&amp;gt;&quot;&gt;
                                                    &lt;ItemTemplate&gt;
                                                        &lt;input type=&quot;checkbox&quot; name=&quot;recordId&quot; onclick=&quot;javascript:setTotalAmount(&#39;GvOurBookDetails&#39;,&#39;&lt;%#Container.DataItemIndex%&gt;&#39;,this.checked);&quot;
                                                            value=&#39;&lt;%#DataBinder.Eval(Container,&quot;DataItem.[voucher_ledger_id]&quot;)%&gt;&#39; /&gt;
                                                        &lt;input type=&quot;hidden&quot; id=&quot;amount_&lt;%#Container.DataItemIndex %&gt;&quot; value=&#39;&lt;%#iif(eval(&quot;Debit_Amount&quot;)=&quot;0.00&quot;,eval(&quot;Credit_Amount&quot;),eval(&quot;Debit_Amount&quot;)) %&gt;&#39; /&gt;
                                                    &lt;/ItemTemplate&gt;
                                                    &lt;HeaderStyle HorizontalAlign=&quot;Left&quot; CssClass=&quot;Freezing&quot;&gt;&lt;/HeaderStyle&gt;
                                                &lt;/asp:TemplateField&gt;
                                                &lt;asp:TemplateField HeaderText=&quot;Voucher No.&quot; SortExpression=&quot;generated_voucher_No&quot;
                                                    ControlStyle-CssClass=&quot;commonGridHeader &quot; ControlStyle-Width=&quot;20&quot;&gt;
                                                    &lt;ItemTemplate&gt;
                                                        &lt;a style=&quot;cursor: pointer&quot; onclick=&quot;validate_me(&lt;%#eval(&quot;voucher_id&quot;)%&gt;)&quot;&gt;
                                                            &lt;%#DataBinder.Eval(Container.DataItem, &quot;generated_voucher_No&quot;)%&gt;
                                                        &lt;/a&gt;
                                                    &lt;/ItemTemplate&gt;
                                                &lt;/asp:TemplateField&gt;
                                                &lt;asp:BoundField HeaderText=&quot;Date&quot; DataField=&quot;Voucher_date&quot; SortExpression=&quot;cheque_date&quot;  /&gt;
                                                &lt;asp:BoundField HeaderText=&quot;Cheque No.&quot; DataField=&quot;cheque_no&quot; SortExpression=&quot;cheque_no&quot; /&gt;
                                                &lt;asp:BoundField  HeaderText=&quot;Debit Amt.&quot;  DataField=&quot;Debit_Amount&quot; SortExpression=&quot;Debit_Amount&quot; /&gt;
                                                &lt;asp:BoundField HeaderText=&quot;Credit Amt.&quot; DataField=&quot;Credit_Amount&quot; SortExpression=&quot;Credit_Amount&quot; /&gt;
                                                &lt;asp:BoundField HeaderText=&quot;Ledger Narration&quot; DataField=&quot;Narration&quot; SortExpression=&quot;Narration&quot;
                                                    ControlStyle-Width=&quot;32&quot; /&gt;
                                                &lt;asp:BoundField HeaderText=&quot;Party Name&quot; DataField=&quot;party_name&quot; SortExpression=&quot;party_name&quot;
                                                    ControlStyle-Width=&quot;15&quot; /&gt;
                                                &lt;asp:BoundField HeaderText=&quot;Slip No.&quot; DataField=&quot;pay_slip_no&quot; SortExpression=&quot;pay_slip_no&quot; /&gt;
                                                &lt;asp:BoundField HeaderText=&quot;S&quot; DataField=&quot;voucher_status&quot; SortExpression=&quot;voucher_status&quot;
                                                    ControlStyle-Width=&quot;4&quot; /&gt;
                                                &lt;asp:TemplateField HeaderText=&quot;&quot;&gt;
                                                    &lt;ItemTemplate&gt;
                                                        &lt;input type=&quot;hidden&quot; id=&#39;hf_amt_type_ourbook&#39; name=&#39;hf_amt_type_ourbook&#39; value=&#39;&lt;%#DataBinder.Eval(Container,&quot;DataItem.[amt_type]&quot;)%&gt;&#39; /&gt;
                                                    &lt;/ItemTemplate&gt;
                                                &lt;/asp:TemplateField&gt;
                                                &lt;asp:TemplateField&gt;
                                                    &lt;%--    &lt;ItemTemplate&gt;
              &lt;asp:TextBox ID=&quot;Voucher_id&quot; width=&quot;0px&quot;  style=&quot;display:none&quot; runat=&quot;server&quot; Text=&#39;&lt;%#DataBinder.Eval(Container,&quot;DataItem.[voucher_id]&quot;)%&gt;&#39;&gt;&lt;/asp:TextBox&gt;
              &lt;/ItemTemplate&gt;--%&gt;
                                                &lt;/asp:TemplateField&gt;
                                            &lt;/Columns&gt;
                                            &lt;FooterStyle Font-Bold=&quot;True&quot; ForeColor=&quot;White&quot; /&gt;
                                            &lt;RowStyle CssClass=&quot;label&quot; /&gt;
                                            &lt;SelectedRowStyle Font-Bold=&quot;True&quot; /&gt;
                                            &lt;PagerStyle ForeColor=&quot;White&quot; HorizontalAlign=&quot;Center&quot; /&gt;
                                            &lt;HeaderStyle CssClass=&quot;Freezing&quot; Font-Bold=&quot;True&quot; /&gt;
                                            &lt;%--&lt;AlternatingRowStyle BackColor=&quot;White&quot; /&gt;--%&gt;
                                        &lt;/asp:GridView&gt;
                                        &lt;/ContentTemplate&gt;
                                        &lt;Triggers&gt;  &lt;asp:AsyncPostBackTrigger ControlID =&quot;GvOurBookDetails&quot; EventName=&quot;Sorting&quot;/&gt;&lt;/Triggers&gt;
                                        &lt;/asp:UpdatePanel&gt;</pre>
Posted

Hi,

Remove the below line from your GridView code, I think it will work:
ASP.NET
<triggers><asp:asyncpostbacktrigger controlid="GvBankBookDetails" eventname="Sorting" xmlns:asp="#unknown" /></triggers>
 
Share this answer
 
Comments
satej746 19-Jul-12 4:58am    
I have remove this line as per ur suggestion but still it does not work.........
please look at this carefully

XML
<form id="form1"  runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
        <table>
        <tr>
        <td>
        <asp:TextBox ID="txt1" runat="server">
        </td>
        </tr>
//1st grid starts hear
<tr>
 <td>
<table>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
 <asp:GridView ID="grvDemo" runat="server" AllowSorting="true" AutoGenerateColumns="true" EnableSortingAndPagingCallbacks="TRUE">
        <Triggers> <asp:AsyncPostBackTrigger ControlID="grvDemo" EventName="grvDemo_Sorting" /> </Triggers>
</ContentTemplate>
</UpdatePanel>
</table>
 </td>
</tr>
//1st grid ends &&2nd grid starts hear
<tr>
<td>
<Table>
    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
        <asp:GridView ID="GridView1" runat="server" AllowSorting="true" AutoGenerateColumns="true" EnableSortingAndPagingCallbacks="TRUE">
        <Triggers><asp:AsyncPostBackTrigger ControlID="GridView1" EventName="GridView1_Sorting" /></Triggers>
</ContentTemplate>
</UpdatePanel>
</table>
</td>
</tr>
//2nd grid ends.
    </div>
    </form>
 
Share this answer
 
v4
Comments
satej746 19-Jul-12 6:40am    
I have tried this also but still it does not work ... here i am showing u my code.... pleasse help me ........



<form id="form1" runat="server">
<div>

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">

<table>
<tr>
<td>
<asp:TextBox ID="txt1" runat="server">
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<contenttemplate>
<asp:GridView ID="grvDemo" runat="server" AllowSorting="true" AutoGenerateColumns="true" EnableSortingAndPagingCallbacks="TRUE">


<Triggers> <asp:AsyncPostBackTrigger ControlID="grvDemo" EventName="grvDemo_Sorting" /> </Triggers>

</td>
<td>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<contenttemplate>
<asp:GridView ID="GridView1" runat="server" AllowSorting="true" AutoGenerateColumns="true" EnableSortingAndPagingCallbacks="TRUE">


<Triggers><asp:AsyncPostBackTrigger ControlID="GridView1" EventName="GridView1_Sorting" /></Triggers>

</td>
</tr>
</table>

</div>
</form>


Partial Class Import_ETL_Popup
Inherits Syscon.Web.UI.Page.baseClass
Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
bindgrid()
End Sub
Public Function bindgrid()
Dim dt As DataTable = DBHelper.ExecuteDataset(FunctionFactory.GetConnectionString(), CommandType.Text, "select user_name,password from tbl_user_mst").Tables(0)
grvDemo.DataSource = dt
grvDemo.DataBind()
Dim dt1 As DataTable = DBHelper.ExecuteDataset(FunctionFactory.GetConnectionString(), CommandType.Text, "select password,user_name from tbl_user_mst order by user_name").Tables(0)
GridView1.DataSource = dt1
GridView1.DataBind()
End Function

Protected Sub grvDemo_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles grvDemo.Sorting
Dim dt As DataTable = DBHelper.ExecuteDataset(FunctionFactory.GetConnectionString(), CommandType.Text, "select user_name,password from tbl_user_mst order by user_name desc").Tables(0)
grvDemo.DataSource = dt
grvDemo.DataBind()
End Sub

Protected Sub GridView1_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GridView1.Sorting
Dim dt1 As DataTable = DBHelper.ExecuteDataset(FunctionFactory.GetConnectionString(), CommandType.Text, "select password,user_name from tbl_user_mst order by user_name desc").Tables(0)
GridView1.DataSource = dt1
GridView1.DataBind()
End Sub
End Class
sandeep nagabhairava 19-Jul-12 6:53am    
please look at my code carefully...

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