Loading ...

Passing multiple command arguments on a button click in a Repeater | CodeAsp.Net

Passing multiple command arguments on a button click in a Repeater

 /5
0 (0votes)

Today I have learnt one thing that will help you too. so that I want to share this to you as usual.

So my task is to delete the row from repeater on the basis of two parameters

ASPX Page :

 <asp:Button ID="button1 Text="Accept" CommandName="Accept" 
CommandArgument ='<%# Eval("ID1") + "," + Eval("ID2") %>' runat="server" />

 ASPX.CS :

 

 protected void rpt1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Accept")
{
string[] commandArgsAccept = e.CommandArgument.ToString().Split(new char[] { ',' });
commandArgsAccept[0].ToString();//it gives first ID
commandArgsAccept[1].ToString();//it gives second ID

}


}

 

 

Hope this will help

Comments (6)

   
Shaitender
Shaitender
nice post..
thanks a lot
1/13/2009
 · 
by
   
Waleed Eissa
Nice trick, thanks for sharing
4/7/2009
 · 
by
   
Ghulam Haider
Excellent receipt. Bundle of thanks
5/14/2009
 · 
by
   
Bala
Nice Post. Thanks for sharing
6/4/2009
 · 
by
   
Sameer
Thanx fo rthe excellent post
6/8/2009
 · 
by
   
Susheel
Susheel
I use to adopt your approach most of the time. But do you think using 'data keys' is more efficient way of achieving the same? May be you can help in deciding which approach is better.
11/16/2009
 · 
by

Top Posts