How to add Label control to DataList?

J

Jameel

Hi Coders,

How do i Add a Lable control to DataList to show the Count Files which
belong the current Category.

i have a DataList which displays categoryName,Description and File counter
(coutn the images belong to category), i able to display first 2 values from
database, but how to dispalyg the image counted data in DataList ?
Here is my code which doesnt working:(i am using code behind to pull the
data from DB)
<ItemTemplate>

<table cellpadding=10 style="font: 11px verdana" border="0" class="border"
width="100%" height="160">

<tr><td valign="top"><div class="thumb"><a href='<%#
DataBinder.Eval(Container.DataItem, "CatID",
"ShowThumbnails.aspx?qsCatID={0}") %>' ><img align="top"
src="Images/splash.gif"></a></div></td></tr>


<tr><td>Category: <b><%#DataBinder.Eval(Container.DataItem,
"CategoryName")%></b><br>

Description: <%#DataBinder.Eval(Container.DataItem, "Description")%><br>

Files Count:<b><asp:Label ID="lblCountFiles" runat="server"></asp:Label>
</b></td></tr></table>

</ItemTemplate>

in code behind file it gives me an error that "lblCountFiles" not declared.
 
G

Guest

It seems you are trying to refer to the Label directly in your code behind.
You will have to use FindControl() method of DataListItem in your
IteamDataBound event to get the label object. And using that object you can
set the value.

Hope that helps. If not please post the code behind code as well so that it
can be checked for possible errors.

Regards,
HP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top