varunmaggo's say

Getting better never stops!

GridView – Pass multiple values to Command Argument

leave a comment »

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

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];
       }
}
Advertisement

Written by Varun Maggo

November 28, 2011 at 6:20 am

Posted in ASP.NET, C#.NET

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.