Please help. I have the following - ListView and its two handlers AdminUsersListView_ItemEditing, AdminUsersListView_Load.
请帮助。我有下面的- ListView和它的两个处理程序adminuserslistview_itemedit, AdminUsersListView_Load。
<asp:ListView ID="AdminUsersListView" runat="server"
onitemediting="AdminUsersListView_ItemEditing" onload="AdminUsersListView_Load"
DataKeyNames="UserId">
<LayoutTemplate>
<table cellpadding="2" runat="server" id="usersTable">
<tr runat="server" id="itemPlaceholder" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><asp:LinkButton ID="EditButton" runat="server" Text="Edit" CommandName="Edit" /></td>
<td><asp:Label ID="NameLabel" runat="server" Text='<%# Eval("UserName") %>' /></td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr>
<td><asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" /><asp:LinkButton ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" /></td>
<td><asp:Label runat="server" ID="NameLabel" AssociatedControlID="NameTextBox" Text="Name"/><asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("UserName") %>' MaxLength="50" /></td>
</tr>
</EditItemTemplate>
</asp:ListView>
After it is compiled i see usual page with table and Edit button against each row, i click on the button, post back is sending but nothing is happening.
编译完成后,我看到每行都有一个带有表格和编辑按钮的常规页面,我点击按钮,回帖正在发送,但是什么都没有发生。
Handlers are the following:
处理程序如下:
protected void AdminUsersListView_ItemEditing(Object sender, ListViewEditEventArgs e)
{
}
protected void AdminUsersListView_Load(Object sender, EventArgs e)
{
try
{
Int32 itemCount = Request["itemCount"] == null ? 10 : Int32.Parse(Request["itemCount"]);
Int32 itemPage = Request["itemPage"] == null ? 0 : Int32.Parse(Request["itemPage"]);
List<String> currentRoleList = Roles.GetRolesForUser().ToList();
UsersManager usersManager = new UsersManager();
IEnumerable<DbDataRecord> userList = usersManager.getAllowedUsersForRole(currentRoleList).ToList();
userList = userList.Skip(itemCount * itemPage).Take(itemCount);
AdminUsersListView.DataSource = userList;
AdminUsersListView.DataBind();
}
catch (Exception exceptionData)
{
Log.setMessage(exceptionData);
}
}
Question - why i always see ItemTemplate and cannot see EditTemplate?
问题-为什么我总是看到ItemTemplate而看不到EditTemplate?
Thanks in advance, Art.
提前谢谢,艺术。
2 个解决方案
#1
1
Can you try data binding outwith the load event?
能否尝试使用load事件进行数据绑定?
#2
1
Answer is to directly set index of editing item / row like this :
回答是这样直接设置编辑项/行索引:
protected void lvwCustomers_ItemEditing(object sender, ListViewEditEventArgs e)
{
CloseInsert();
lvwCustomers.EditIndex = e.NewEditIndex;
BindList();
}
Detailed description can be found here : http://geekswithblogs.net/rashid/Default.aspx
详细的描述可以在这里找到:http://geekswithblogs.net/rashid/Default.aspx
#1
1
Can you try data binding outwith the load event?
能否尝试使用load事件进行数据绑定?
#2
1
Answer is to directly set index of editing item / row like this :
回答是这样直接设置编辑项/行索引:
protected void lvwCustomers_ItemEditing(object sender, ListViewEditEventArgs e)
{
CloseInsert();
lvwCustomers.EditIndex = e.NewEditIndex;
BindList();
}
Detailed description can be found here : http://geekswithblogs.net/rashid/Default.aspx
详细的描述可以在这里找到:http://geekswithblogs.net/rashid/Default.aspx