Dynamic content in a Gridview
        Posted  
        
            by mariki
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by mariki
        
        
        
        Published on 2010-03-12T23:21:36Z
        Indexed on 
            2010/03/12
            23:27 UTC
        
        
        Read the original article
        Hit count: 233
        
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 :)
© Stack Overflow or respective owner