473,408 Members | 2,888 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,408 software developers and data experts.

How to change LabelText in DataList

Hi all,

I thought, that this is an usual thing, but Im wrong.

I have a DataList control and there is a Label control. I need to change the
Text propertz of the Label control. How to do it.
Here is my function I want to use, but it is not working. I can Find Label
in DataListItem, but the change is not dispalyed.
public void ConnectionCheck(DataListItem dlItem, string connection)
{
Label lblSourceConnectionStringStatus =
(Label)dlItem.FindControl("lblSourceConnectionStri ngStatus");

if(!Check(connection))
{
lblSourceConnectionStringStatus.Text = "Connection Error";
lblSourceConnectionStringStatus.ForeColor =
System.Drawing.Color.Red;
}
else
{
lblSourceConnectionStringStatus.Text = "Connection OK";
lblSourceConnectionStringStatus.ForeColor =
System.Drawing.Color.Green;
}
}
protected void dlDTDefinitions_ItemCommand(object source,
DataListCommandEventArgs e)
{
CheckConnections(e.Item);
}

What shoud I to do to display new value of the text properties?

Thanks
Mirek
Nov 25 '05 #1
1 2337
Hi Mirek,

Welcome to ASPNET newsgroup.
Regarding on the changing Lable Text in DataList items problem, I think
this is not possible due to the DataList(also any other template databound
control's databinding model...). The DataList's item content are generated
from DataSource during databinding. After that, the data is stored in
viewstate and can not be modifed directly. Also, we can not modify any
nested sub control's properties in normal postback event. If we need to
update the item's value in DataList, we have to change the underlying
datasource and rebind the DataList control with the updated DataSource....

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| From: "Mirek Endys" <Mi****@community.nospam>
| Subject: How to change LabelText in DataList
| Date: Fri, 25 Nov 2005 13:55:23 +0100
| Lines: 42
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <OK**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: gw.coty.cz 195.47.52.129
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:360894
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi all,
|
| I thought, that this is an usual thing, but Im wrong.
|
| I have a DataList control and there is a Label control. I need to change
the
| Text propertz of the Label control. How to do it.
| Here is my function I want to use, but it is not working. I can Find
Label
| in DataListItem, but the change is not dispalyed.
|
|
| public void ConnectionCheck(DataListItem dlItem, string connection)
| {
| Label lblSourceConnectionStringStatus =
| (Label)dlItem.FindControl("lblSourceConnectionStri ngStatus");
|
| if(!Check(connection))
| {
| lblSourceConnectionStringStatus.Text = "Connection Error";
| lblSourceConnectionStringStatus.ForeColor =
| System.Drawing.Color.Red;
| }
| else
| {
| lblSourceConnectionStringStatus.Text = "Connection OK";
| lblSourceConnectionStringStatus.ForeColor =
| System.Drawing.Color.Green;
| }
| }
|
|
| protected void dlDTDefinitions_ItemCommand(object source,
| DataListCommandEventArgs e)
| {
| CheckConnections(e.Item);
| }
|
| What shoud I to do to display new value of the text properties?
|
| Thanks
| Mirek
|
|
|

Nov 28 '05 #2

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

Similar topics

0
by: John Doe | last post by:
Hi all, I've created a pie-chart with Crystal Reports (the VStudio version) and can't seem to change the labeltext on this chart. It now displays a text like "Sum of datatable.field" and I would...
1
by: Steven K | last post by:
Hello, I am using a User Control (ctlHeader.ascx). My problem is that I can't change the text of my literal control "ltlPricingHeader" in the file MyPage.aspx. I can bring in the user control...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
6
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
3
by: rn5a | last post by:
I want to change the background color of a row in a DataList when the mouse is moved over a row. This is how I tried but it doesn't change the background color of a row in the DataList when the...
3
by: =?Utf-8?B?RXJpY2E=?= | last post by:
I have a lable control in a repeater and 2 link buttons. The lable is named lblCurrentPage and the link buttons are named "Prev" and "Next". Once the page is uploaded and viewed through the...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
4
by: Peter | last post by:
I have a DataList and each item in the datalist has an imge, I want to change the datalist item image on the client side when user clicks a button. How would I do that with JavaScript, does anyone...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...

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.