在gridview中的asp.net按钮中传递多个参数
我在 gridview 中有一个 TemplateField 列,里面有一个按钮。
没有键值(当然这不是我设计的),但另一方面,在比较每个单列时没有冗余,因为它们是事件,并且有某些东西的“开始日期”和“结束日期”这不可能同时发生两次。
我已经考虑过使用这些值和所有值进行选择,但我只希望按钮将大约五个参数传递给给定函数。
我已经测试过:
<asp:Button CommandArgument='<%# Eval("day")%>' ID="Button2" runat="server" Text="Button" />
它工作正常,单击行的日期已经过去,并且可以通过以下方式检索:
e.CommandArgument.ToString();
在 GridView_RowCommand 处理程序中。
我如何传递多个参数?我考虑过用一个分隔字符连接(不会那么糟糕),但除了还不知道如何去做(不想投资一个糟糕的解决方案)之外,我想要一个更聪明的解决方案。
I have a TemplateField column in a gridview with a button inside of it.
There is NO key value (surely that was not designed by me) , but in the other hand there aren't redundancies when comparing each single column, because they are events, and there is "starting date" and "ending date" of something that could not happen twice at the same time.
I've already figured selecting with these values and all, but I just want the button to pass about five arguments to a given function.
I've tested:
<asp:Button CommandArgument='<%# Eval("day")%>' ID="Button2" runat="server" Text="Button" />
And it works properly, the day of the clicked row is passed, and could be retrieved through:
e.CommandArgument.ToString();
in the GridView_RowCommand
handler.
How do I pass more than one argument? I've thought about concatenating with a separating character (wouldn't be that bad) but besides not knowing how to do it yet (didn't want to invest in a poor solution) I want a smarter one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法可能是通过按钮访问 GridView 行并以这种方式访问值:
The easiest way may be to access the GridView row via the button and access the values that way: