CommandField that varies Edit/Delete button presence per row

Discussion in 'ASP .Net' started by Kevin Frey, Nov 19, 2006.

  1. Kevin Frey

    Kevin Frey Guest

    When I display a list of records in a GridView, I want to be able to vary
    the presence of the Edit and Delete buttons per row depending on eg. the
    user's security permissions for that row, or attributes associated with the
    record (eg. a purchase order that has been dispatched to a supplier cannot
    be deleted).

    I figure I'm going to need a custom version of CommandField, but I'm not
    sure what it's behaviour should be exactly (still coming to grips with this
    separation of render versus databinding).

    My instinct at this stage is I need to create the controls "in advance" and
    then use visibility to turn the control invisible if the test-case (eg.
    permissions) dictates it.

    Should I be doing this visible/invisible switch in a data binder? Or can I
    actually achieve this earlier in the InitializeCell( ) method? (and even if
    that is possible, is is good practice to do so).


    Kevin Frey, Nov 19, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.