简体   繁体   English

按钮属性: - commandName和CommandArguments

[英]button properties:- commandName and CommandArguments

在Button Control工具中使用的CommandName和CommandArguments属性之间的基本区别是什么。如何在编程期间使用它(使用C#)?

CommandName : Gets or sets the command name associated with the Button control that is passed to the Command event eg Delete, Edit,... CommandName:获取或设置与传递给Command事件的Button控件关联的命令名称,例如Delete,Edit,...

Have a look at this article http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.commandname.aspx 看一下这篇文章http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.commandname.aspx

CommandArguments : An optional parameter passed to the Command event along with the associated CommandName. CommandArguments:传递给Command事件的可选参数以及关联的CommandName。 The default value is String.Empty. 默认值为String.Empty。

Have a look at this article http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.commandargument.aspx 看看这篇文章http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.commandargument.aspx

These property play role when buttons are nested within container controls such as Repeater, GridView etc. On button click, typically, the container control will raise RowCommand event where you can refer to CommandName and CommandArgument values of button. 当按钮嵌套在容器控件(如Repeater,GridView等)中时,这些属性起作用。在按钮单击时,通常,容器控件将引发RowCommand事件,您可以在其中引用按钮的CommandName和CommandArgument值。 CommandName allows to different between different buttons on the same row (Edit, Delete, Select etc) while CommandArgument is generally row identifier (can be index or primary key of the data being bound). CommandName允许同一行上的不同按钮(编辑,删除,选择等)之间不同,而CommandArgument通常是行标识符(可以是被绑定数据的索引或主键)。 Most of containers has a default mechanism to fill CommandArgument with row index if not specified. 如果未指定,大多数容器都有一个默认机制来使用行索引填充CommandArgument。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM