Leon
Leon

Reputation: 581

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?

Upvotes: 0

Views: 633

Answers (1)

Emanuele
Emanuele

Reputation: 664

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.

Upvotes: 0

Related Questions