Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding a TemplateField conditionally

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
I am making use of an asp:GridView control and in it have the following TemplateField:

<asp:TemplateField HeaderText="Delete" >
<ItemTemplate>
<asp:ImageButton ID="imgbtnDeleteEntry" runat="server" ImageUrl="~/Images/gifs/delete.gif" AlternateText="Delete" ToolTip="Delete Entry" CommandName="DeleteEntry" CommandArgument='<%# Eval("id") %>' OnClientClick="return confirm('Are you sure you want to delete this entry?');" />
</ItemTemplate>
</asp:TemplateField>

I want to be able to set this TemplateField's Visible property in the page load event. This may be set to true or false based on the status of the user (i.e. administrator or otherwise).

The index of the column (within the GridView) will not remain the same value - as many other fields are set up dynamically before this TemplateField.
As such I want to be able to set the Visible property against the TemplateField with the ImageButton ('imgbtnDeleteEntry') in it.
How can I do this?

Thanks in advance.
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top