扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Dim Row As GridViewRow Dim SelectedValue As String = ViewState("SelectedValue") If SelectedValue Is Nothing Then Return End If ' 检测选择的行是哪个并重新选中它 For Each Row In GridView1.Rows Dim KeyValue As String = GridView1.DataKeys(Row.RowIndex).Value If (KeyValue = SelectedValue) Then GridView1.SelectedIndex = Row.RowIndex End If Next End Sub Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) ' 保存选中行的索引 If (Not GridView1.SelectedIndex = -1) Then ViewState("SelectedValue") = GridView1.SelectedValue End If End Sub Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) ' 重置选中索引 GridView1.SelectedIndex = -1 End Sub Sub GridView1_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) ' 重置选择索引 GridView1.SelectedIndex = -1 End Sub |
<asp:GridView AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="au_id" DataSourceID="SqlDataSource1" EnableSortingAndPagingCallbacks="True" ID="GridView1" runat="server"> …… </asp:GridView> |
<PagerTemplate> <asp:LinkButton CommandName="Page" CommandArgument="First" ID="LinkButton1" runat="server" Style="color: white"><< First</asp:LinkButton> <asp:LinkButton CommandName="Page" CommandArgument="Prev" ID="LinkButton2" runat="server" Style="color: white">< Prev</asp:LinkButton> [Records <%= GridView1.PageIndex * GridView1.PageSize %> - <%= GridView1.PageIndex * GridView1.PageSize + GridView1.PageSize - 1 %>] <asp:LinkButton CommandName="Page" CommandArgument="Next" ID="LinkButton3" runat="server" Style="color: white">Next ></asp:LinkButton> <asp:LinkButton CommandName="Page" CommandArgument="Last" ID="LinkButton4" runat="server" Style="color: white">Last >></asp:LinkButton> </PagerTemplate> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者