473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 4256
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dude | last post by:
Below is the code - it is finding the control, and there is no error, just not assigning the text to the label <asp:DataList id="dlGoals" runat="server" onEditCommand="myListEditHandler"...
9
by: jjack100 | last post by:
I want to set the text value of a label that is within a datalist in the codebehind. Does this have to be done in the databound event? Simplified example: <asp:DataList id="dlItem"...
1
by: | last post by:
I have a label control that I've embedded in a datalist template. I will be binding data to that label. I want to run a string formatting function on the database text before it is injected into...
7
by: rn5a | last post by:
How can I place a Label control in the FooterTemplate of a DataList control? I tried this <script runat="server"> Sub Page_Load(obj As Object, ea As EventArgs) Dim dblTotal As Double Dim...
2
by: rn5a | last post by:
Consider the following code: <script runat="server"> Sub ShowData(obj As Object, ea As EventArgs) lblDate.Text = DateTime.Now.ToString("d") lblDate.DataBind() End Sub </script> <form...
1
by: Steve Hershoff | last post by:
I'm using VS 2003, and need to extract the text from an asp label in my code-behind file. The label is part of a DataList's ItemTemplate. I've noticed that in my ascx file (we're using User...
0
by: rn5a | last post by:
One of the columns in a SQL Server 2005 DB table is named 'OrderDate' which stores the date & time on which an order has been placed. Since the 'OrderDate' of a particular order will be the same, I...
0
by: lamarant | last post by:
OK...I have a datalist that, in each row, has control and a label. What I want to happen is for the text in the label to update when its associated control is clicked. Here's what I have so...
1
by: Jim in Arizona | last post by:
On one page I have a datalist where a message is bound to a label. On another page I have the datalist which allows for the insert of new message as well as being able to edit those messages. The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.