Click here to Skip to main content
15,909,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my C# code..here i used two int variables..but it is taking only one variable..
Is this declaration of two variable is correct??

What I have tried:

C#
protected void lnkbutAdd_Click(object sender, EventArgs e)
   {

    var AssignGroupId = ((LinkButton)sender).CommandArgument;
    var UserId = ((LinkButton)sender).CommandArgument;

}
Posted

1 solution

Most of the time it is hard to use two different values in command argument, I think the better way is to use only one variable but separate it with some separator
see below snippet
HTML
//use it like
CommandArgument='<%#Eval("AssignGroupId")+","+ Eval("UserId")%>'


and then
C#
//read it like below code
string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
string AssignGroupId = commandArgs[0];
string UserId = commandArgs[1];
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900