Search code examples
c#asp.netdatarepeatercommandargument

Can we pass multiple eval field in one command argument in Repeater Control?


can we pass multiple eval field in one command argument.

my code is here

<asp:TemplateField HeaderText="Details" SortExpression="source"> <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%#Eval("source") %>' CommandName="Download" Text='<%#Eval("source") %>'></asp:LinkButton> </ItemTemplate> </asp:TemplateField>

I want to be pass many Eval field in single command argument with command name if possible please show any reference.


Solution

  • If this is what you are asking as you didnt provide any code snippet i'm assuming like this

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

    In code behind you can use retrieve values like this

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