Dynamic content in a Gridview
- by mariki
I have a gridview with couple of columns,I want to achieve the following:
If user is NOT authorized display normal columns.
If user IS authorized: set mouseover event for first column text and display some buttons (that are not available for NOT authorized users) in a second column when user hover over(using javascript) the first column.
I am have 2 difficulties:
The first one where and when should I create the buttons?
I have 2 options,
I can create those button on design time, in gridviews template and just set Visible value to false and then in codebehind set it to true if user is authorized.
The second option would be creating this buttons dynamically in gridview_RowCreated event (or any other event) if user is authorized.
The Second difficulty is setting the javascript event to show the buttons, the event should be added only if user is authorized!
Note that event and buttons should have some kind of id match for Javascript function to know what should it hide/unhide when event is triggered.
What should I do, what is the best practice?
I know this is a long question, but please try to help :)