Help with GridView and an button column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.
 
Back
Top