以下是我的列表视图标记
<asp:ListView ID="ListView1" runat="server" DataKeyNames="SNO"
DataSourceID="SqlDataSource1" InsertItemPosition="LastItem" OnItemCreated="DateCalculation" OnItemUpdated="Update">
如您所见,我有两个事件DateCalculation和UpdateButton。日期计算事件如下:-
protected void DateCalculation(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.InsertItem)
{
TextBox txtbox1 = e.Item.FindControl("DateTakenPlaceTextBox") as TextBox;
txtbox1.Text = DateTime.Now.ToString("yyyy/MM/dd");
}
}
Now when i try to add similar event to Update i.e.
protected void Update(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.InsertItem)
{
TextBox txtbox2 = e.Item.FindControl("AmountTextBox") as TextBox;
if (txtbox2.Text == null)
{
}
}
}
我收到以下错误:
“更新”没有重载与委托
“System.EventHandler”匹配
这是否意味着我必须编写 eventargs 而不是 Listviewitemeventargs?我想访问 listviewitems 所以我需要 Listviewitemeventargs。任何人都可以建议做什么?