473,399 Members | 3,919 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,399 software developers and data experts.

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 2091
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.FindControl("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.DataKeys(Item.ItemIndex) 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*************@TK2MSFTNGP15.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.FindControl("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.DataKeys(Item.ItemIndex) 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
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...
0
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...
2
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...
3
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,...
0
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...
0
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...
1
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...
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.