Dynamically adding buttons to each row: how?

From: who be dat? (whatever_at_dot.com)
Date: 06/24/04

  • Next message: olap: "web.config"
    Date: Thu, 24 Jun 2004 00:08:47 -0400
    
    

    I'm working on a web application that will use some datagrid and asp.net, an
    asp.net Forum to be exact where people can leave posts and respond to posts
    others have left. One page in particular displays rows with an
    "interesting" column. What's interesting about this column is that it
    displays some links followed by text (the message someone left), all in the
    same column. These links represent actions a user can do. One link lets a
    user reply to a message, the other link lets a user quote a message, link #3
    lets a user delete a message, while the fourth link let's a user edit a
    message. I'd like for these links to be buttons. I'm relatively new to
    ASP.Net although I'm picking it up fairly well. Datagrids in particular a
    bit of a fit although I'm slowly learning the in's and out's of them.
    However, I've hit of a break wall. I think I can do what I want with
    templates and such. When a button is called, I can catch this event using
    the ItemCommand event and write the necessary code to deal with what was
    clicked. Two problems I'm having:

    1) All four buttons are not shown for each row everytime. At a minimum, a
    row will display only two buttons, the reply and quote buttons. Edit will
    only show up if the user who is logged in created the message for that
    particular row. If the user didn't create that message in a given row, then
    that user shouldn't see an edit button for that message. The delete button
    works in a similar fashion although there are conditions where others can
    delete a message. The point is, there are a total of four buttons that
    maybe visible for each row but on some rows only 2 or 3 buttons will be
    shown.

    2) Due to the fact I like the way things look, I prefer to put the buttons
    and text in the same column. Essientlly, the buttons will be at the top of
    a column with the text of a message shown below the buttons, again in the
    same column.

    I suppose if I have to, I can put the buttons in their own column and have
    the text in a seperate column, but I'd rather have them both in the same
    column while figuring out a way have buttons present or not present on a per
    row basis.

    Is this possible? I've seen quite a few examples of adding controls (such
    as buttons) to a column, but I've never seen an example where each row could
    have a different amount of buttons in the same column unless the datagrid
    has gone to edit mode for a row, for example, which I'd rather not do.
    Plus, I'm not seeing much where it comes adding controls and adding text
    after a control although I suppose I could add a label after the buttons in
    the column and fill it with the text representing the message...

    Any thoughts on this would be greatly appreciated. I order an ASP.Net book
    on controls which was recommended on DatagridGirl.com, but it won't be here
    for a day or two. I'd really like to get past this ASAP.

    Sorry for the long post and thanks!

    Chris Smith


  • Next message: olap: "web.config"