0

When I pass multiple arguments via

<asp:Button runat="server" ID="btnUpdate" Text="Update" 
            CssClass="btn btn-sm btn-success" 
            CommandName="UpdateCoordinator" 
            CommandArgument='<%# Bind("iUserID") & "," & Bind("siteID")%>' 
            CausesValidation="false" />

And in code behind I attempt to split the CommandArgument like this:

Dim commandArgs As String() = e.CommandArgument.ToString().Split(New Char() {","})
Dim iUserID As Integer = Val(commandArgs(0))
Dim iSiteID As Integer = Val(commandArgs(1))

I am only getting the first argument and the error

System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'

Any assistance to point out what I am missing would be fantastic!

2
  • Based on your title this question and related answers might be helpful: stackoverflow.com/questions/9822827/… Commented Mar 23, 2020 at 4:53
  • how is your new Char() array taking string members. Commented Mar 23, 2020 at 6:29

1 Answer 1

0

I solved this by using Container.DataItem() in the definition of the Button.

<asp:Button runat="server" ID="btnUpdate" Text="Update" CssClass="btn btn-sm btn-success" CommandName="UpdateCoordinator" CommandArgument='<%# Container.DataItem("iUserID").ToString() & "," & Container.DataItem("siteID").ToString() %>' CausesValidation="false" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.