我是vb.net的新手
我在来自DB的listview中显示数据。我希望获得用户选择的一些细节。 这是home.aspx中的My Listview
<asp:SqlDataSource ID="datasource1" runat="server"
ConnectionString="<%$ ConnectionStrings:test %>"
></asp:SqlDataSource>
<asp:ListView ID="ListView1" runat="server" OnItemCommand="data_OnItemCommand" DataKeyNames= "dataSortID" allowsorting="true" DataSourceID="datasource1">
<LayoutTemplate>
<asp:DataPager ID="dpListView" runat="server" PageSize="4" >
<Fields> <asp:NextPreviousPagerField ButtonType="Link"
ShowFirstPageButton="true"
ShowPreviousPageButton="true"
ShowLastPageButton="false"
ShowNextPageButton ="false"/>
<asp:NumericPagerField ButtonType="Link" NextPageText="more.." />
<asp:NextPreviousPagerField ButtonType="Link"
ShowFirstPageButton="false"
ShowPreviousPageButton="false"
ShowLastPageButton="true"
ShowNextPageButton ="true"/>
</Fields>
</asp:DataPager>
<br />
<br />
<div id="ItemPlaceHolderContainer" runat="server" >
<span id="ItemPlaceHolder" runat="server"></span>
</div>
</LayoutTemplate>
<ItemTemplate >
<div >
<%# Eval("Username")%>
<asp:LinkButton runat="server" ID="UserAccept" Text="Accept" CommandName="select" CommandArgument="<%# Eval("dataSortID")%>" />
<asp:LinkButton runat="server" ID="UserDecline" Text="Decline" CommandName="Decline" CommandArgument="<%# Eval("dataSortID")%>"/>
</div>
</ItemTemplate>
</asp:ListView>
这是我的home.aspx.vb
Protected Sub data_OnItemCommand(ByVal sender As Object, _
ByVal e As ListViewCommandEventArgs)
If String.Equals(e.CommandName, "select") Then
TextBox1.Text = "It worked perfectly"
Dim dataItem As ListViewDataItem = e.Item
var routeLabel = (Label)item1.FindControl("routenameLabel");
lblResponseRoute.Text = routeLabel.ID.ToString();
**TextBox2.Text = [sortID of the selected item]**
Else
TextBox1.Text = "Not worked"
End If
End Sub
所以我无法获得相应所选项目的sortid。
任何人都可以帮我解决这个问题。