This is a simple code, and not sure why CommandArgument
is not being passed to my event handler. Here is my aspx code:
</td>
<asp:Button ID="Button1" runat="server" Text="Update Me"
CommandName="Update Name" ComandArgument="First,Second,Third,Fourth"
OnCommand = "Button1IsClicked" />
</td>
And here is my code behind:
Protected Sub Button1IsClicked(ByVal sender As Object, ByVal e As EventArgs )
Dim btn As Button = CType(sender, Button)
Dim item As RepeaterItem = CType(btn.NamingContainer, RepeaterItem)
Dim CommandName As String = btn.CommandName
Dim MyArgs As String() = btn.CommandArgument.Split(",")
Dim CommandArgument1 As String = MyArgs(0)
' and so on
End Sub
Please note that my button is one of the Repeater Item. I get the CommandName
and CommandText
fine, but MyArgs is always an empty string (btn.CommandArgument
is always empty). CommandArgument
in btn and Repeater Item is a blank string. I am expecting "First,Second,Third,Fourth"
as its value.
I also tried with OnClick as event, but to no avail. Any idea what may be going wrong?