简体   繁体   中英

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,...

Have a look at this article 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. The default value is String.Empty.

Have a look at this article 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. 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). Most of containers has a default mechanism to fill CommandArgument with row index if not specified.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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