GridView排序,无需刷新页面 [英] GridView sort without page refresh

查看:95
本文介绍了GridView排序,无需刷新页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中具有网格视图,我想启用此排序功能.但是,当我对数据进行排序时,页面会重定向或刷新.我想避免在单击grdiview上的排序时刷新此页面,因为我有以下代码的grdvw

I have grid view in asp.net and i want to make this enabled sorting.But When i sort data the page redirects or freshed.I want avoid this page refresh when i click on sort on grdiview i have folowing code of grdvw

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" OnRowCreated="myGridView_ItemCreated8"

      EnableSortingAndPagingCallbacks=true    BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="groupID,timestamp"

         DataSourceID="SqlDataSource1" Font-Names="Arial" Font-Size="Smaller" HorizontalAlign="Center"

         Width="100%" AllowSorting="True">
         <RowStyle ForeColor="Black" BorderColor="#BFBFBF" BorderStyle="Solid" BorderWidth="1px" Font-Names="Arial" Font-Size="9pt" HorizontalAlign="Center" VerticalAlign="Middle" Wrap="False" />
         <Columns>
             <asp:BoundField DataField="groupID" HeaderText="Group ID" ReadOnly="True" SortExpression="groupID" />
             <asp:BoundField DataField="groupName" HeaderText="Group Name" SortExpression="groupName" />
             <asp:BoundField DataField="vehicleID" HeaderText="Vehicle ID" SortExpression="vehicleID" />
             <asp:BoundField DataField="description" HeaderText="Description" SortExpression="description" />
             <asp:BoundField DataField="timestamp" HeaderText="Date/Time" ReadOnly="True" SortExpression="timestamp" />
             <asp:BoundField DataField="latitude" HeaderText="Lat" SortExpression="latitude" />
             <asp:BoundField DataField="longitude" HeaderText="Long" SortExpression="longitude" />
             <asp:BoundField DataField="altitude" HeaderText="Alt" SortExpression="altitude" />
             <asp:BoundField DataField="speedKPH" HeaderText="Speed" SortExpression="speedKPH" />
             <asp:BoundField DataField="distanceKM" HeaderText="Distance" SortExpression="distanceKM" />
             <asp:BoundField DataField="odometerKM" HeaderText="OdoMeter" SortExpression="odometerKM" />
             <asp:BoundField DataField="odometerOffsetKM" HeaderText="odometerOffsetKM" SortExpression="odometerOffsetKM"

                 Visible="False" />
         </Columns>
         <FooterStyle BackColor="White" ForeColor="#000066" />
         <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
         <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
         <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
         <AlternatingRowStyle ForeColor="Black" />
     </asp:GridView>

推荐答案

您无法避免使用ASP.NET服务器控件进行回发.您可以将网格包装在UpdatePanel中,以免影响页面的其余部分,也可以重新设计并使用基于JavaScript的网格.
You can''t avoid the postback using the ASP.NET server control. You can wrap the grid in an UpdatePanel so it doesn''t affect the rest of the page, or you can re-engineer and use a JavaScript based grid.


是的.您可以在不使用AJAX刷新页面的情况下进行操作.您可以将gridview放置在更新面板中,并根据需要编写代码...不会刷新页面.它只刷新网格/
Yes. You can do it without page refresh by AJAX. u can place the gridview inside of the update panel and write the code as u want ... it wont refresh the page. it refresh the grid only/


您可以使用jQuery动态创建网格并应用任何命令,而无需刷新页面.
You can dynamically create the grid using jQuery and apply any command without refreshing the page.


这篇关于GridView排序,无需刷新页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆