473,776 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with label inside a datalist

Hi,
I have a datalist, this datalist has a label for each item called lblId,
this label hold the ID of each item. I need to write a procedure that will
use the value of the label of each item, I'm using the FindControl method
but the return value is aways "".

How do I get the text of the labels??
Thanks!
Nov 18 '05 #1
2 2108
Jos
Bruno Piovan wrote:
Hi,
I have a datalist, this datalist has a label for each item called
lblId, this label hold the ID of each item. I need to write a
procedure that will use the value of the label of each item, I'm
using the FindControl method but the return value is aways "".

How do I get the text of the labels??


Did you use FindControl properly, like this (I use VB.NET):

Dim lblId As Label = CType(Item.Find Control("lblId" ),Label)

A better way to find the IDs is to set the DataKeyField property
of the datalist to the name of the database field (probably "ID"),
and use DataList1.DataK eys(Item.ItemIn dex) to get the value
of the ID.

--

Jos
Nov 18 '05 #2
Yes,
I was using findcontrol that way.

but DataKeys worked great, I don't need to have the ID shwon.

working great now,
I love you man.

thanks
"Jos" <jo************ ***@fastmail.fm > wrote in message
news:Oj******** *****@TK2MSFTNG P15.phx.gbl...
Bruno Piovan wrote:
Hi,
I have a datalist, this datalist has a label for each item called
lblId, this label hold the ID of each item. I need to write a
procedure that will use the value of the label of each item, I'm
using the FindControl method but the return value is aways "".

How do I get the text of the labels??


Did you use FindControl properly, like this (I use VB.NET):

Dim lblId As Label = CType(Item.Find Control("lblId" ),Label)

A better way to find the IDs is to set the DataKeyField property
of the datalist to the name of the database field (probably "ID"),
and use DataList1.DataK eys(Item.ItemIn dex) to get the value
of the ID.

--

Jos

Nov 18 '05 #3

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

Similar topics

1
3185
by: Doug | last post by:
The html below shows DataList "DiscountList" nested within DataList "EventItemList". DiscountList contains a Label control. I'm trying to find the label, using FindControl, during EventList_ItemCreated (below the html), but it's always <undefined value> (null). Everything else works fine. Eventually I need to set the value of the label depending up the Count of the DataView "dvDiscount". For now I'll settle for just finding the damn...
0
1126
by: Andrew Westgarth | last post by:
Hi all, i'm struggling with a page idea I have. I need to write a page with an A to Z list of available schools in the area. I only want to display the letters in the A to Z which have school information under them, i.e. A,b,c,d,f if no schools beginning with e are available. My chosen page layout out would be
2
1237
by: Andy Sutorius | last post by:
Hi, Are datalists able to have labels inside of the ItemTemplate? Every time I try to place a label in the Item Template it does not show up in the code behind/intellisense. FYI the datalist contains items that can be placed in shopping cart. I want the label to notify the user that the placement of the item into the shopping was successful. Thanks,
3
1967
by: Danny Tuppeny | last post by:
Hi all, I've got a DataList that's bound to a datasource with two columns (well, two that matter). One is called GigDate, and one is called RescheduledFromDate. GigDate doesn't allow NULLs, but the RescheduledFromDate does. In general, only a GigDate will be supplied, but if a Gig is rescheduled, the GigDate is copied to RescheduledFromDate, and the GigDate then becomes the "new" date. I'm using a DataList instead of a Grid because...
0
1131
by: Maran | last post by:
We have come across a situation that I thinks not many have. Grateful for all responses. Regards Maran ************* * Scenario A DataList binds to a DataRow, with "RegionName" och "RegionShortName",
0
1081
by: Patrick.O.Ige | last post by:
I have a Datalist below its inside another datalist In IE it renders fine which means the first td cell with width = 130px is wider than the others So any text in there if its too long goes to the next line. But when i view it in FIREFOX if the text is too long it doesn't go to the next line the cell just goes wider.. Any ideas how to fix the cell in firefox. Thanks <asp:DataList id="dg" runat="server" Width="450px">
1
1578
by: David | last post by:
Hi, This one appears a little strange to me. Here is the scenario. I load a datalist the first time a page is run. The page has a !IsPostback and the datalist gets loaded at this point. I have a button on the page, where I want to read the contents of the datalist. As an example that I have found on MS...
7
2532
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
0
1093
by: Bieniu | last post by:
I have DataList control on my own contro land it is bind to SqlDataSource control. My problem is that DataList is getting needed data twice what is for me very strange. I have some code in OnSelected event of SqlDataSource, and i was suprised when it was fired twice for every page loading. His is code of datalist: <tr> <td style="width: 5%;"> </td> <td colspan="3">
0
9628
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
9464
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
10120
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...
0
8952
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
6722
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5367
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4031
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
2
3622
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2860
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.