I have a question about what would be the best practice for creating a conditional statement for a GridView in ASP.NET. I have a badge number that is being passed into a new page containing a GridView and depending on that badge number, I want to have it check whether or not the user has permissions (from another db table) and display the “Edit” button if they have permission.
I guess I’m not sure about how to accomplish this. I have tried searching and the best I can come up with is to do it during a databound event.
Any insight on this topic would be great! Thanks!
Here is the code I have right now (the auto generated edit button for gridviews):
<Columns>
<asp:CommandField ShowEditButton="True" />
etc
etc
etc
</Columns>
In the row databound function of the gridview you could make a call to the other db and work out whether to show the button or not. You can find the control in the gridview and then set it to be invisible.