Home All Groups Group Topic Archive Search About

How to add Label control to DataList?

Author
24 Nov 2005 7:04 AM
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.

Author
24 Nov 2005 8:29 AM
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

Show quoteHide quote
"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.
>
>
>

Bookmark and Share