Home > ASP.Net > Pass multiple values to Command Argument

Pass multiple values to Command Argument


Hi

try this example:

<ItemTemplate>                          
<asp:Button ID="btnTest" runat="Server" CommandName="Test" Text="Select" CommandArgument='<%#Eval("carid") + ","+Eval("year") %>' />                      
</ItemTemplate>

And in code behind :- 

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Test")
        {
            string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
            Label1.Text= commandArgs[0];
            Label2.Text = commandArgs[1];
       }
   }

Good Luck

Advertisements
Categories: ASP.Net
  1. Ashwini
    July 16, 2009 at 6:33 am

    Hey this is very helpful. thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: