What is the click event for an asp.net grid view?
In windows C# data grid view , I use cell cli开发者_StackOverflow社区ck event and what i have to use for asp.net c# grid view ?
Short answer, there isn't a handler for an individual cell in the ASP.NET GridView. However, you could still use JavaScript, or the Command architecture built into GridViews, to achieve a similar result. For instance, you could make the data in the cells HyperLinks, with a NavigateUrl property set to run a JS function that changes the cell color, disables/enables controls, etc. You could use CSS to make these links look like ordinary text if you wanted. You could also set up CommandButtons like "Select", "Edit", "View" etc, that can then be handled server-side and customized to do pretty much whatever you want.
For the ASP.Net GridView, you will want to create a hyperlink or linkbutton control in the item template and assign it to have the "CommandName" attribute with one of several options.
- Select
- Add
- Edit
- Update
- Delete
These will trigger the appropriate RowEditing, RowDeleting, etc. methods available.
You can also create your own command names and put them into the CommandName field, these custom commands will trigger the RowCommand event and you can process them accordingly. Use the CommandArgument parameter to provide additional details, such as a row Id.
精彩评论