我想在我的asp.net应用程序中使用listview控件,并在itemtemplate图像按钮中使用。我想如果我点击这个按钮,我可以使div块可见= true,并用listview行中的数据填充控件。
我的列表视图:
<asp:ListView runat="server" ID="myListView" OnItemCommand="myListView_ItemCommand"
OnSelectedIndexChanging="myListView_SelectedIndexChanging">
<LayoutTemplate>
<table id="UserList" border="1" cellpadding="0" cellspacing="0">
<tr style="background-color:#ccdaeb">
<th>
<span class="spanpading"><asp:Label ID="lblNameHeader" runat="server" Text="_Name"></asp:Label></span> </th>
<th>
<span class="spanpading"><asp:Label ID="lblCompanyHeader" runat="server" Text="_Firma"></asp:Label></span></th>
<th >
<span class="spanpading"><asp:Label ID="lblVonHeader" runat="server" Text="_gültig ab"></asp:Label></span></th>
<th >
<span class="spanpading"><asp:Label ID="lblBisHeader" runat="server" Text="_gültig bis"></asp:Label></span></th>
<th >
<span class="spanpading"><asp:Label ID="lblErstellerHeader" runat="server" Text="_erstellt von"></asp:Label></span> </th>
<th align="left">
</th>
<th align="left">
</th>
<th align="left">
</th>
</tr>
<tr id="itemPlaceholder" runat="server"></tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr onmouseover="this.style.backgroundColor='#87CEFA'"
onmouseout="this.style.backgroundColor='#ffffff'">
<td align="left"><span class="spanpading"><asp:Label ID="lblname" Text='<%# Eval("NAME") %>' runat="server" /></span></td>
<td align="left"><span class="spanpading"><asp:Label ID="lblcompany" Text='<%# Eval("COMPANY") %>' runat="server" /></span></td>
<td align="left"><span class="spanpading"><asp:Label ID="lblVon" Text='<%# Eval("TIMEFROM") %>' runat="server" /></span></td>
<td align="left"><span class="spanpading"><asp:Label ID="lblBis" Text='<%# Eval("TIMETO") %>' runat="server" /></span></td>
<td align="left"><span class="spanpading"><asp:Label ID="lblErsteller" Text='<%# Eval("CREATOR") %>' runat="server" /></span></td>
<td align="left"><asp:ImageButton ID="imgDelete" runat="server" ToolTip="löschen" ImageUrl="images/delete.gif" /></td>
<td align="left"><asp:ImageButton ID="imgUpdate" runat="server" ToolTip="ändern" ImageUrl="images/edit.gif" CommandName="update" CommandArgument='<%# Container.DataItemIndex %>' /></td>
<td align="left"><asp:ImageButton ID="imgEmail" runat="server" ToolTip="Zugangsdaten senden" ImageUrl="images/send.gif" /></td>
</tr>
</ItemTemplate>
<EmptyDataTemplate>
<h4>Es wurden keine Einträge gefunden</h4><br/>
</EmptyDataTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #E5EDF5;" onmouseover="this.style.backgroundColor='#87CEFA'"
onmouseout="this.style.backgroundColor='#E5EDF5'">
<td align="left"><span class="spanpading"><asp:Label ID="lblname" Text='<%# Eval("NAME") %>' runat="server" /></span></td>
<td align="left"><span class="spanpading"><asp:Label ID="lblcompany" Text='<%# Eval("COMPANY") %>' runat="server" /></span></td>
<td align="left"><span class="spanpading"><asp:Label ID="lblVon" Text='<%# Eval("TIMEFROM") %>' runat="server" /></span></td>
<td align="left"><span class="spanpading"><asp:Label ID="lblBis" Text='<%# Eval("TIMETO") %>' runat="server" /></span></td>
<td align="left"><span class="spanpading"><asp:Label ID="lblErsteller" Text='<%# Eval("CREATOR") %>' runat="server" /></span></td>
<td align="left"><asp:ImageButton ID="imgDelete" runat="server" ToolTip="löschen" ImageUrl="images/delete.gif" /></td>
<td align="left"><asp:ImageButton ID="imgUpdate" runat="server" ToolTip="ändern" ImageUrl="images/edit.gif" CommandName="update" CommandArgument='<%# Container.DataItemIndex %>' /></td>
<td align="left"><asp:ImageButton ID="imgEmail" runat="server" ToolTip="Zugangsdaten senden" ImageUrl="images/send.gif" /></td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
这是m&lt; commandItem的代码:
protected void myListView_SelectedIndexChanging(object sender, EventArgs e)
{
//
}
protected void myListView_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "update")
{
int index = Convert.ToInt32(e.CommandArgument);
Label lbName = (Label)myListView.Items[index].FindControl("lblname");
Label lbFirma = (Label)myListView.Items[index].FindControl("lblcompany");
Label lbVon = (Label)myListView.Items[index].FindControl("lblVon");
Label lbBis = (Label)myListView.Items[index].FindControl("lblBis");
//Übergabe an die Div Update Box
draggablebox.Visible = true;
}
}
这是错误消息: