469,913 Members | 2,107 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

How to add Label control to DataList?

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.
Nov 24 '05 #1
1 4133
HP
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

"Jameel" wrote:
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.

Nov 24 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Dude | last post: by
9 posts views Thread by jjack100 | last post: by
7 posts views Thread by rn5a | last post: by
2 posts views Thread by rn5a | last post: by
1 post views Thread by Steve Hershoff | last post: by
reply views Thread by rn5a | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.