Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - How to change LabelText in DataList

 
Thread Tools Search this Thread
Old 11-25-2005, 12:55 PM   #1
Default 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




Mirek Endys
  Reply With Quote
Old 11-28-2005, 02:52 AM   #2
Steven Cheng[MSFT]
 
Posts: n/a
Default RE: How to change LabelText in DataList
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" <>
| 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: <OKKOB#>
| 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
|
|
|



Steven Cheng[MSFT]
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
master page does not change due to preinit event not firing franchise63 General Help Related Topics 0 02-13-2008 09:18 AM
Why We Resist Change @ The TechZone Silverstrand Front Page News 0 09-07-2006 12:01 PM
Dune Extended Edition - where is the layer change? John DVD Video 0 02-16-2006 09:43 PM
If I could change the LotR movies... Opticreep DVD Video 33 03-03-2004 12:36 PM
Can't Change IRQs in Windows 2000 Alicia White A+ Certification 8 09-01-2003 08:54 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46