C# 在gridview的asp.net按钮中传递多个参数

C# 在gridview的asp.net按钮中传递多个参数,c#,asp.net,gridview,arguments,templatefield,C#,Asp.net,Gridview,Arguments,Templatefield,我在gridview中有一个TemplateField列,其中有一个按钮 没有关键值(当然不是我设计的),但在另一方面,在比较每一列时没有冗余,因为它们是事件,并且存在不可能同时发生两次的事件的“开始日期”和“结束日期” 我已经考虑过使用这些值和所有值进行选择,但我只希望按钮向给定函数传递大约五个参数 我测试过: <asp:Button CommandArgument='<%# Eval("day")%>' ID="Button2" runat="server" Text=

我在gridview中有一个TemplateField列,其中有一个按钮

没有关键值(当然不是我设计的),但在另一方面,在比较每一列时没有冗余,因为它们是事件,并且存在不可能同时发生两次的事件的“开始日期”和“结束日期”

我已经考虑过使用这些值和所有值进行选择,但我只希望按钮向给定函数传递大约五个参数

我测试过:

<asp:Button  CommandArgument='<%# Eval("day")%>'  ID="Button2" runat="server" Text="Button" />
GridView\u行命令中
处理程序


如何传递多个参数?我曾考虑过使用分隔字符进行连接(不会那么糟糕),但除了不知道如何进行连接(不想投资一个糟糕的解决方案)之外,我还想要一个更智能的解决方案。

最简单的方法可能是通过按钮访问GridView行,并以这种方式访问值:

void Button2_Click(object o, EventArgs e) {
    Button myButton = (Button)o;
    GridViewRow row = (GridViewRow)muButton.Parent.Parent;

    string value1 = row.Cells[0].Text;
    string value2 = row.Cells[1].Text;
    ...
}

我想问同样的问题。。!!!您可以这样连接:
CommandArgument='
-但是是的,我同意这是一个肮脏的解决方案。@MarceloRamires…我不是在开玩笑。。。唯一不同的是,我在vb上工作。@jjj事实上,我也在vb.NET上工作,但当我说我使用vb时,stackoverflow中的人往往不会回答问题(即使这个问题不太涉及代码隐藏编程哦……真的吗?!这没什么大的不同。。!!
void Button2_Click(object o, EventArgs e) {
    Button myButton = (Button)o;
    GridViewRow row = (GridViewRow)muButton.Parent.Parent;

    string value1 = row.Cells[0].Text;
    string value2 = row.Cells[1].Text;
    ...
}