选择例子
前端代码:
<asp:ListView ID="ListView1" runat="server"
onselectedindexchanging="ListView1_SelectedIndexChanging">
<LayoutTemplate>
<table id="Table1" runat="server" border="0" style="">
<tr runat="server" id="itemPlaceholder" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<%#Eval("ID") %>
</td>
<td>
<asp:Label ID="idLabel" runat="server" Text=''<%# Eval("name") %>'' />
</td>
<td>
<asp:Label ID="xLabel" runat="server" Text=''<%# Eval("age") %>'' />
</td>
<td>
<asp:Button ID="SelectButton" CommandName="Select" runat="server" Text="选择" />
</td>
</tr>
</ItemTemplate>
<SelectedItemTemplate>
<tr style="background-color:Blue">
<td>
<%#Eval("ID") %>
</td>
<td>
<asp:Label ID="idLabel" runat="server" Text=''<%# Eval("name") %>'' />
</td>
<td>
<asp:Label ID="xLabel" runat="server" Text=''<%# Eval("age") %>'' />
</td>
<td>
<asp:Button ID="SelectButton" CommandName="Select" runat="server" Text="选择" />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
后台代码:
protected void ListView1_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
{
ListView1.SelectedIndex = e.NewSelectedIndex;
Bind();
}
電會念極旗鷹?
<asp:ListView ID="ListView1" runat="server" OnSorting="ListView1_Sorting">
<LayoutTemplate>
<table id="Table1" runat="server" border="0" style="">
<tr>
<td>
<asp:LinkButton ID="LinkButton1" CommandArgument="ID" runat="server" CommandName="Sort">ID&
|