我有两个不同命令的按钮
<asp:LinkButton ID="lbEditDetails" Text="Edit..." runat="server" CommandName="EditDetails" CssClass="EditAdults" CommandArgument=<%# DataBinder.Eval(Container.DataItem, "number_slept") & "-" & DataBinder.Eval(Container.DataItem, "booking_ref") %>></asp:LinkButton>
<asp:LinkButton ID="lbSubmitDetails" Text="Submit..." Visible="false" runat="server" CommandName="SubmitDetails" CssClass="SubmitAdults" CommandArgument=<%# DataBinder.Eval(Container.DataItem, "booking_ref") %>></asp:LinkButton>
我的转发器已经
了<asp:Repeater id="dgBookings" runat="server" OnItemDataBound="ItemDB" OnItemCommand="EditDetails">
但是我需要在点击该按钮时运行SubmitDetails
,并在点击该按钮时运行EditDetails
。
任何想法
由于
杰米
更新
我的中继器
<asp:Repeater id="dgBookings" runat="server"
OnItemDataBound="ItemDB" OnItemCommand="ItemCommand">
我的子命令
Sub ItemCommand(ByVal Sender as Object, ByVal e as RepeaterCommandEventArgs)
If e.CommandName = "EditDetails" Then
EditDetails() <---- This is where it's dying
Else If e.CommandName = "SubmitDetails" Then
SubmitDetails()
End If
End Sub
Sub EditDetails(ByVal Sender as Object, ByVal e as RepeaterCommandEventArgs)
Dim strPassedItems = e.CommandArgument
Dim strNumberSlept As String = e.CommandArgument.Split("-"C)(0)
Dim strPassedBookingRef As String = e.CommandArgument.Split("-"C)(1)
CType(e.Item.FindControl("ddlEditAdults"), dropdownlist).Visible = True
CType(e.Item.FindControl("ddlEditChildren"), dropdownlist).Visible = True
End Sub
当我收到此错误时,我有什么问题吗
Argument not specified for parameter 'e' of 'Public Sub EditDetails(Sender As Object, e As System.Web.UI.WebControls.RepeaterCommandEventArgs)'.
由于
杰米
更新
Sub ItemCommand(ByVal Sender as Object, ByVal e as RepeaterCommandEventArgs)
If e.CommandName = "EditDetails" Then
EditDetails(sender,e)
Else If e.CommandName = "SubmitDetails" Then
SubmitDetails()
End If
End Sub
sender,e
是我需要投入的全部内容。
由于
杰米
答案 0 :(得分:2)
尝试编写一般的OnItemCommand事件处理程序,并根据单击的按钮的CommandName属性决定运行哪个方法:
protected void itemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "EditDetails")
{
EditDetails();
}
else if (e.CommandName == "SubmitDetails")
{
SubmitDetails();
}
}
}
并将转发器标记设置为:
<asp:Repeater id="dgBookings" runat="server" OnItemDataBound="ItemDB" OnItemCommand="itemCommand">