我有listtemplate和Selecteditemtemplate的列表视图。我有一个命令名=“选择”的选择按钮。我无法将listview带入selectedItem模板。我的代码是 -
<asp:ListView ID="Listview1" runat="server" DataKeyNames="BikeTypeId"
OnItemDeleted="delete" OnSelectedIndexChanged="ListView1_SelectedIndexChanged"
OnItemEditing="editing">
<LayoutTemplate>
<table>
<tr>
</tr>
<asp:PlaceHolder ID="itemplaceholder" runat="server"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td> <%# DataBinder.Eval(Container.DataItem,"BikeTypeId") %></td>
<td> <%# DataBinder.Eval(Container.DataItem,"Name") %></td>
<td height="20px"> <%# DataBinder.Eval(Container.DataItem,"Description") %></td>
<td><asp:Image ID="i" runat="server" ImageUrl='<%# "Handler.ashx?b_id=" + Eval ("BikeTypeId") %> ' /></td>
<td><asp:Button ID="select" runat="server" CommandName="Select" Text="Select" /></td>
</tr>
</ItemTemplate>
<SelectedItemTemplate>
<tr bgcolor="yellow"></tr>
<td> <%# DataBinder.Eval(Container.DataItem,"BikeTypeId") %></td>
<td> <%# DataBinder.Eval(Container.DataItem,"Name") %></td>
<td height="20px"> <%# DataBinder.Eval(Container.DataItem,"Description") %></td>
<td><asp:Image ID="i" runat="server" ImageUrl='<%# "Handler1.ashx?b_id=" + Eval("BikeTypeId") %> ' /></td>
<td><asp:Button ID="Edit" CommandName="Edit" runat="server" Text="Edit" /></td>
<td><asp:Button ID="Delete" runat="server" Text="Delete" CommandName="Delete" /></td>
</tr>
</SelectedItemTemplate>
<EditItemTemplate>
<tr>
<td> <asp:Label ID="ID" runat="server" Text='<%# Bind("BikeTypeId") %>'><asp:Label></td>
<td><asp:TextBox ID="Name" runat="server" Text='<%# Bind("Name") %>'>' ></asp:TextBox></td>
<td><asp:TextBox ID="Des" runat="server" Text='<%# Bind("Descrription") %>' TextMode="MultiLine" ></asp:TextBox> </td>
<td><asp:FileUpload runat="server" ID="File" /></td>
<td><asp:Button ID="Update" runat="server" Text="Update" CommandName="Update" /></td>
<td><asp:Button ID="Cancel" runat="server" Text="Cancel" CommandName="Cancel" /></td>
</tr>
</EditItemTemplate>
背后的代码是 -
protected void ListView1_SelectedIndexChanged(object sender, ListViewSelectEventArgs e)
{
Listview1.SelectedIndex = e.NewSelectedIndex;
string id = Listview1.SelectedDataKey.Value.ToString();
Response.Write(id);
bind();}
单击选择按钮时没有变化。请帮助.....