Question

I am working with a web application in VS2010. I want to change the visibility of a Template Column based on which button is pressed on the webpage. This is what I am currently doing:

<asp:TemplateColumn >
    <ItemTemplate>
        <asp:LinkButton id="hlArchive" runat="server" ToolTip="ARCHIVE" 
                        Text="A" CommandName="Archive" CausesValidation="false" 
                        Visible="False">
            </asp:LinkButton>
   </ItemTemplate>
</asp:TemplateColumn>

However, this leaves a small table on the screen. Doing this gets rid of the empty table:

<asp:TemplateColumn Visible="False">

But I cannot figure out how to change the visibility in the code when the time is right since there is no ID field. Is there something similar to this that will let me do it?

hlArchive.Visible=true;
Was it helpful?

Solution

do you try this

  // mn is your datagrid ID and set the Index of the column
  mn.Columns[0].Visible = true;

I tried the above code it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top