0

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?

uraimo
  • 19,081
  • 8
  • 48
  • 55
Kishor
  • 27
  • 2

1 Answers1

0

ComandArgument is misspelled. It needs to be CommandArgument in the following line:

CommandName="Update Name" CommandArgument="First,Second,Third,Fourth"

Tony Hinkle
  • 4,706
  • 7
  • 23
  • 35
  • Did this address the issue? If yes, then please mark it as the answer. If not, please edit to update your code and I'll delete this answer. – Tony Hinkle May 12 '15 at 18:35
  • Thanks a lot Tony, that is perfect. I was relying on MS intellisence to tell me that but no compilation error. Thanks again. – Kishor Jun 13 '15 at 18:03