473,804 Members | 3,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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,De scription 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"><d iv class="thumb">< a href='<%#
DataBinder.Eval (Container.Data Item, "CatID",
"ShowThumbnails .aspx?qsCatID={ 0}") %>' ><img align="top"
src="Images/splash.gif"></a></div></td></tr>
<tr><td>Categor y: <b><%#DataBinde r.Eval(Containe r.DataItem,
"CategoryName") %></b><br>

Description: <%#DataBinder.E val(Container.D ataItem, "Description")% ><br>

Files Count:<b><asp:L abel ID="lblCountFil es" runat="server"> </asp:Label>
</b></td></tr></table>

</ItemTemplate>

in code behind file it gives me an error that "lblCountFi les" not declared.
Nov 24 '05 #1
1 4292
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,De scription 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"><d iv class="thumb">< a href='<%#
DataBinder.Eval (Container.Data Item, "CatID",
"ShowThumbnails .aspx?qsCatID={ 0}") %>' ><img align="top"
src="Images/splash.gif"></a></div></td></tr>
<tr><td>Categor y: <b><%#DataBinde r.Eval(Containe r.DataItem,
"CategoryName") %></b><br>

Description: <%#DataBinder.E val(Container.D ataItem, "Description")% ><br>

Files Count:<b><asp:L abel ID="lblCountFil es" runat="server"> </asp:Label>
</b></td></tr></table>

</ItemTemplate>

in code behind file it gives me an error that "lblCountFi les" not declared.

Nov 24 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5361
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" onUpdateCommand="myListUpdateHandler" onCancelCommand="myListCancelHandler" onDeleteCommand="myListDeleteHandler" DataKeyField="ID"> <ItemTemplate>
9
2584
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" runat="server"> <ItemTemplate> <asp:Label ID="lblItemPrice" runat="server" /> </ItemTemplate> </asp:DataList>
1
3896
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 the datalist. When I try to do this, I get a "... does not exist in the current context. I need to know how to target the control. If I were writing Flash actionscript, it would be something like
7
2534
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 sqlReader As SqlDataReader
2
3857
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 runat="server"> <asp:Label ID="lblDate" OnDataBinding="ShowData" runat="server"/>
1
2804
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 Controls here) I can't set the Text property in the opening tag when writing out the <asp:Label....</asp:Labeltags. I have to put my text between the opening and closing tags, like you would with a regular HTML tag. So this might be the cause of...
0
1190
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 want to display the 'OrderDate' in a Label control & the rest of the records should be displayed in a DataList. This is how I approached it: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) Dim dSet As DataSet...
0
1071
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 far...just need to get that label updating. The Control's OnChange Event: Private Sub Rating_Changed(ByVal sender As Object, ByVal e As AjaxControlToolkit.RatingEventArgs) Dim SQL As String Dim ExecSP As New dbFun
1
2660
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 editing (EditItemTemplate) has a textbox that loads the message into its text property. The problem I'm running into is working with vbCrLf and <brinterchangeably between the textbox on the admin page and the label on the general message page. I...
0
9704
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9572
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10319
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9132
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.