Pass multiple Eval field in one command argument in Repeater Control

01 Jul, 20211 min read

This is the most common problem that generally users face while dealing with Repeater control. I gave this solution in Stackoverflow. want to post it here for users coming from search

Add the below snippet in in template

1CommandArgument='<%#Eval("ScrapId")+","+ Eval("UserId")%>'

In code behind you can use retrieve values like this

1protected void GridViews_RowCommand(object sender, GridViewCommandEventArgs e)
2{
3    if (e.CommandName == "Comment")
4    {
5        string[] commandArgs = e.CommandArgument.ToString().Split(new char[] { ',' });
6        string scrapid = commandArgs[0];
7        string uid = commandArgs[1];
8    }
9}