473,769 Members | 4,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 lblSourceConnec tionStringStatu s =
(Label)dlItem.F indControl("lbl SourceConnectio nStringStatus") ;

if(!Check(conne ction))
{
lblSourceConnec tionStringStatu s.Text = "Connection Error";
lblSourceConnec tionStringStatu s.ForeColor =
System.Drawing. Color.Red;
}
else
{
lblSourceConnec tionStringStatu s.Text = "Connection OK";
lblSourceConnec tionStringStatu s.ForeColor =
System.Drawing. Color.Green;
}
}
protected void dlDTDefinitions _ItemCommand(ob ject source,
DataListCommand EventArgs e)
{
CheckConnection s(e.Item);
}

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

Thanks
Mirek
Nov 25 '05 #1
1 2353
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****@communi ty.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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: gw.coty.cz 195.47.52.129
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP10.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3608 94
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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 lblSourceConnec tionStringStatu s =
| (Label)dlItem.F indControl("lbl SourceConnectio nStringStatus") ;
|
| if(!Check(conne ction))
| {
| lblSourceConnec tionStringStatu s.Text = "Connection Error";
| lblSourceConnec tionStringStatu s.ForeColor =
| System.Drawing. Color.Red;
| }
| else
| {
| lblSourceConnec tionStringStatu s.Text = "Connection OK";
| lblSourceConnec tionStringStatu s.ForeColor =
| System.Drawing. Color.Green;
| }
| }
|
|
| protected void dlDTDefinitions _ItemCommand(ob ject source,
| DataListCommand EventArgs e)
| {
| CheckConnection s(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
405
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 like to change it to "Total items sold". Where and how can I accomplish that? TIA Jonathan
1
2121
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 as long as it's static. Any help with this would be appreciated. -- Thanks in advance,
4
4043
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 work:( Thanks My CheckBoxList in the DataList Below
6
9595
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 only print the Parent Category once, regardless of how many child items are in it. So my perfect output would look something like:
3
10303
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 (where is the child DataList).... But in case I want to make Edit in this child DataList it is not working... No edit template showed... :( this is a code that i use for the child DataList... Edit command // this is for child DataList...
3
8894
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 mouse is moved over a row: <script runat="server"> Sub CreateItem(ByVal obj As Object, ByVal ea As DataListItemEventArgs) If (ea.Item.ItemType = ListItemType.Item Or ea.Item.ItemType = ListItemType.AlternatingItem) Then
3
1205
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 browser, all three button id's change. Why is this? I see it has been changed by looking at the source of the web page. I thnk this may be causing a problem in my code because I'm refrencing the controls by the id name I gave them. Is there a way to keep...
3
2811
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 need to control the visibility of a textbox based on a dropdown selection in the datalist's edititem template. To do this, I registered a client script block function and attached a client side handler for the dropdownlist's onchange event in the...
4
3986
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 has an example of how to change a DataList item with JavaScript? Thank You Peter
0
9589
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
9423
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
10216
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
10049
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
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
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
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.