Find Label in listview control

Hello experts. I have a listview control (code attatched). And would like to find the control "lblNoMatches".

How would I do this?

Thanks in advance.

<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" >
                    <div style="float: left; width: 100%; border-top: 2px solid #e20a16; padding-top: 20px; margin-top: 20px;">
                        <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
                    <asp:DataPager ID="DataPager1" runat="server" PagedControlID="ListView1" PageSize="10" style="float: left; width: 100%;">
                            <asp:nextpreviouspagerfield ButtonType="Link" ShowFirstPageButton="False" ShowNextPageButton="False" ShowPreviousPageButton="True" />
                            <asp:numericpagerfield />
                            <asp:nextpreviouspagerfield ButtonType="Link" ShowLastPageButton="False" ShowNextPageButton="True" ShowPreviousPageButton="False" />
                    <asp:HyperLink ID="HyperLinkName" Text='<%# Eval("pagename") %>' NavigateUrl='<%# "page.aspx?id=" + Eval("Page_ID") %>' style="float: left; color: #e20a16; font-weight: bold; margin-bottom: 5px;" runat="server" />
                    <asp:Label ID="LtrlOverview" Text='<%# Eval("pagetext") + "..." %>' style="float: left; width: 100%; color: #605b54; margin-bottom: 15px;" runat="server" />
                    <div style="float: left; width: 100%; border-top: 2px solid #e20a16; padding-top: 20px; margin-top: 20px;">
                        <asp:Label ID="lblNoMatches" Text="Sorry, no matches were found!" runat="server" />

Open in new window

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.

you can call  this method

FindControl("lblNoMatches", ListView1.Controls);

private Control FindControl(string controlID, ControlCollection controls)
        foreach (Control c in controls)
            if (c.ID == controlID)
                return c;
            if (c.HasControls())
                Control cTmp = this.FindControl(controlID, c.Controls);
                if (cTmp != null)
                    return cTmp;
        return null;

Open in new window


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
thomasmuttonAuthor Commented:
that worked great, thanks!
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

From novice to tech pro — start learning today.