Asp gridview rowupdating event not firing
You can hide a Command Field or Button Field based on the position (index) in the Grid View.
This example shows how to edit and update records in a Grid View in ASP. This example is helpful in situations where an administrator needs to edit several records from the database.
Had we used the 'Register Client Script Block', the browser would have executed the Java Script before the text box is on the page.
Following code will show you how you can get Row Index, Product ID and Command Name of the button when user click any button in the Grid View.
For example, you can set the Command Name property to Sort and set the Command Argument property to Ascending to specify a command to sort in ascending order.
Command Name: Command Name property to determine the command to perform.
If it is expensive, this could easily sum up to a large cost. In this example, I am hiding it if the field "Scenario" of the grid shows the text "Actual" for the relevant row of the Row Data Bound event.
I almost gave up and just convert my commandfield to a templatefield but I know it can be done so I keep on searching for it. (Although I'm still not sure what the asker meant about the declarative answer.) If this was based on roles you could use the multiview panel but not sure if you could do the same against a property of the record. In your rowdatabound event you can hide or show the button in it.