简体   繁体   中英

How to enable the GridView Delete Button only for certain rows

I have a GridView with AutoGenerateEditButton enabled and upon clicking the Edit button, it brings up the usual "Update" and "Cancel". I need to add a Delete button only for certain rows. I figured this would go in the Gridview1_RowDataBound function, but I want to know if this is even possible.

For example, I click on Row 13 (a row I don't want the "Delete" button) and it only gives me the option of "Update" and "Cancel".

I then click on Row 17 (a row I do want the "Delete" button) and it gives me "Update", "Cancel", and "Delete".

Or is there a better way to "delete" a row?

You are right. If you use AutoGenerateEditButton you can get the button in RowDataBound event. You can also create your TemplateField with the Button and set the Visible property based on conditions.

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