Help with GridView and an button column

Discussion in 'ASP .Net' started by =?Utf-8?B?Q2hyaXM=?=, Jan 1, 2007.

  1. Hi,
    I added a buttom column to my gridview. When a certain condition is met I
    want to set the visible to True. I did the following but it is not working.

    The button column in the page
    <asp:ButtonField ButtonType="Image" CommandName="DeleteRow" Visible="false"
    ">
    <ItemStyle HorizontalAlign="Center" />
    <HeaderStyle HorizontalAlign="Center" Width="10px" />
    </asp:ButtonField>

    At the GrrdView RowDataBound Event

    Dim _button As ImageButton

    If condition Then

    _button = e.Row.Cells(1).Controls(0)
    _button.Visible = True

    End If

    Any ideas?
    =?Utf-8?B?Q2hyaXM=?=, Jan 1, 2007
    #1
    1. Advertising

  2. Hi,
    I have one suggestion.Initially add placeholder control(instead of
    ImageButtron and making its visible property false) and let its visible
    property be true.

    At the GrrdView RowDataBound Event

    Dim _button As ImageButton

    If condition Then
    //First cast it placeholder control and then add imagebuttton to
    placeholder
    ((placeholder)e.Row.Cells(1).Controls(0)).Add.Controls(_button)

    End If
    Altough i have written pseduo code,you can give it try with little
    modification.
    Hope this helps you out.

    Thanks and Regards,
    Manish Bafna.
    MCP and MCTS.

    "Chris" wrote:

    > Hi,
    > I added a buttom column to my gridview. When a certain condition is met I
    > want to set the visible to True. I did the following but it is not working.
    >
    > The button column in the page
    > <asp:ButtonField ButtonType="Image" CommandName="DeleteRow" Visible="false"
    > ">
    > <ItemStyle HorizontalAlign="Center" />
    > <HeaderStyle HorizontalAlign="Center" Width="10px" />
    > </asp:ButtonField>
    >
    > At the GrrdView RowDataBound Event
    >
    > Dim _button As ImageButton
    >
    > If condition Then
    >
    > _button = e.Row.Cells(1).Controls(0)
    > _button.Visible = True
    >
    > End If
    >
    > Any ideas?
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=, Jan 2, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. carlos perez
    Replies:
    0
    Views:
    406
    carlos perez
    Jun 8, 2004
  2. =?Utf-8?B?V2FyYW4=?=

    HyperLink Column and Button Column in a DataGrid

    =?Utf-8?B?V2FyYW4=?=, Aug 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    596
    =?Utf-8?B?V2FyYW4=?=
    Aug 9, 2005
  3. Keithb
    Replies:
    2
    Views:
    1,119
  4. Keith G Hicks
    Replies:
    3
    Views:
    754
    Keith G Hicks
    Feb 18, 2008
  5. johnsonlim026
    Replies:
    0
    Views:
    925
    johnsonlim026
    Feb 27, 2010
Loading...

Share This Page