Link to home
Start Free TrialLog in
Avatar of ws11
ws11

asked on

Hide and show controls in a ListView's ItemTemplate

Is it possible in a ListView's ItemTemplate to reference a Label in code-behind onload or method?  I want to make visible dynamically each Label control based on my column count of my dataset.
ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ws11
ws11

ASKER

Thanks I realized that this might not be the what I really need.  My item template is a table with the labels filling the td tags.  I also need to dynamically handle each td.  So to be more specific the user will be  importing an excel sheet with an unknown number of columns.  I am currently showing the records in a listview from a sql table that the excel was imported to.  Next I need to allow the user to define each column from a drop down list since each user may have there own proprietary structure in the excel file.  
Avatar of ws11

ASKER

I think I will submit this in a different question.  You accurately answered my question.  Thanks.
Avatar of ws11

ASKER

Is it possible to do something like article ID: 21113426 and place it inside the layout template or item template?

call in code-behind

dynamicTable = Build_Dynamic_Table();


<LayoutTemplate>
    <div class="lvBackground">
    <asp:Table id="dynamicTable" runat="server" />
    </div>
</LayoutTemplate>

or

<ItemTemplate>
    <div class="lvBackground">
    <asp:Table id="dynamicTable" runat="server" />
    </div>
</ItemTemplate>

protected Table Build_Dynamic_Table()
    {
        Table tDynamicTable;
        TableRow trRow;
        TableCell tcCell;

        tDynamicTable = new Table();

        for (int y = 1; y <= 10; y++)
        {
            trRow = new TableRow();
            for (int x = 1; x <= 5; x++)
            {
                tcCell = new TableCell();
                tcCell.Text = "Add text here";
                trRow.Cells.Add(tcCell);
            }

            tDynamicTable.Rows.Add(trRow);
        }

        return tDynamicTable;
    }

Open in new window