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.
ws11Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

guru_samiCommented:
you can use LV ItemDataBound event and do something like this:
Label lbl = e.Item.FindControl("Lable1");
if(lbl!=null)
{ lbl.visible = true or false based on some condition
}
Or post your lv code and with more info on what you are looking for...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ws11Author Commented:
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.  
0
ws11Author Commented:
I think I will submit this in a different question.  You accurately answered my question.  Thanks.
0
ws11Author Commented:
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

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.