I have a label control that I've embedded in a datalist template. I will be
binding data to that label.
I want to run a string formatting function on the database text before it is
injected into the datalist. When I try to do this, I get a "... [control]
does not exist in the current context.
I need to know how to target the control. If I were writing Flash
actionscript, it would be something like
_root.myDatalis t.myLabelInside MyDatalist.Text =
processedTextTh atIAlreadyRanTh roughMyFunction
Is this possible? Am I running into a page lifecycle thing, or?
Thanks for any help. Actual code follows. I'm trying to inject the formatted
variable text into lblCon_Body.
-KF
<asp:DataList runat="server" id="DataList1" DataKeyField="C on_ContentID"
DataSourceID="S qlDataSource1" Width="100%" HorizontalAlign ="Left"
CellPadding="0" >
<ItemTemplate >
<asp:Label Text='<%# Eval("Con_Title ") %>' runat="server"
id="Con_TitleLa bel" Font-Bold="True" Font-Size="Medium" />
<br />
<asp:Label Text='<%# Eval("Con_Bylin eCredit") %>' runat="server"
id="Con_BylineC reditLabel" Font-Italic="True" Font-Size="X-Small"
style="font-size: small; line-height: 15pt; font-style: italic; font-family:
Arial, Verdana, Sans-serif" />
<br />
<br />
<asp:Label Text='<%# Eval("Con_Body" )%>' runat="server" ID="lblCon_Body "
Font-Italic="False" Font-Size="X-Small" style="font-size: small;
line-height: 15pt; font-style: italic; font-family: Arial, Verdana,
Sans-serif" /><br />
<br />
</ItemTemplate>
</asp:DataList> 1 3875
Yes, you can do that, but you have to get a reference to that control first,
using FindControl(id) and casting it as a label.
Here's an example:
foreach(DataLis tItem item in MyDataList.Item s){
((Label)item.Fi ndControl("lblC on_Body")).Text =
processedTextTh atIAlreadyRanTh roughMyFunction ;
}
"ke*****@nospam .nospam" wrote: I have a label control that I've embedded in a datalist template. I will be binding data to that label.
I want to run a string formatting function on the database text before it is injected into the datalist. When I try to do this, I get a "... [control] does not exist in the current context.
I need to know how to target the control. If I were writing Flash actionscript, it would be something like
_root.myDatalis t.myLabelInside MyDatalist.Text = processedTextTh atIAlreadyRanTh roughMyFunction
Is this possible? Am I running into a page lifecycle thing, or?
Thanks for any help. Actual code follows. I'm trying to inject the formatted variable text into lblCon_Body.
-KF <asp:DataList runat="server" id="DataList1" DataKeyField="C on_ContentID" DataSourceID="S qlDataSource1" Width="100%" HorizontalAlign ="Left" CellPadding="0" >
<ItemTemplate >
<asp:Label Text='<%# Eval("Con_Title ") %>' runat="server" id="Con_TitleLa bel" Font-Bold="True" Font-Size="Medium" />
<br />
<asp:Label Text='<%# Eval("Con_Bylin eCredit") %>' runat="server" id="Con_BylineC reditLabel" Font-Italic="True" Font-Size="X-Small" style="font-size: small; line-height: 15pt; font-style: italic; font-family: Arial, Verdana, Sans-serif" />
<br />
<br />
<asp:Label Text='<%# Eval("Con_Body" )%>' runat="server" ID="lblCon_Body " Font-Italic="False" Font-Size="X-Small" style="font-size: small; line-height: 15pt; font-style: italic; font-family: Arial, Verdana, Sans-serif" /><br />
<br />
</ItemTemplate>
</asp:DataList> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dude |
last post by:
Below is the code - it is finding the control, and there is no error,
just not assigning the text to the label
<asp:DataList id="dlGoals" runat="server"
onEditCommand="myListEditHandler"
onUpdateCommand="myListUpdateHandler"
onCancelCommand="myListCancelHandler"
onDeleteCommand="myListDeleteHandler"
DataKeyField="ID">
<ItemTemplate>
|
by: Harry |
last post by:
Hi,
Can anyone tell me why the below code does not work.
I dont get any errors, but nor does the Text for the asp:label get
set.
Thanks in advance as always
H
|
by: MasterChief |
last post by:
I have an insert template textbox that is bound to a field in SQL.
Since it is the insert template it really doesn't have anything in it.
How do I set the default text? Like for example if I have a insert
template field that is databound to a date sql column how can I set the
text to be a default like todays date?
|
by: Paul |
last post by:
I am using Visual Studio.net 2005 (and asp.net 2.0)
Let's say that in a Web Project, I have created a (Dataset?) called
SomeDataset.xsd.
On it I have a TableAdapter called SomeTableTableAdapter and a query called
GetSomeInfoQuery.
In an aspx page I used an ObjectDataSource, and chose as the business object
SomeDataSetTableAdapters.SomeTableTableAdapter, then the method
GetSomeInfoQuery.
|
by: Sam Martin |
last post by:
Hi,
I have got a User Control that contains for the sake of argument, a single
DataList control.
eg.
<asp:DataList id="DataListMain" runat="server" RepeatDirection="Horizontal"
RepeatColumns="4"
Width="100%" GridLines="Vertical">
<ItemTemplate>
| |
by: Nathan Sokalski |
last post by:
I am trying to create a FormView controls in which I access and modify the
the controls in the PagerTemplate programmatically. However, I continue to
recieve the following error:
Object reference not set to an instance of an object.
I am attempting to access the controls in my PagerTemplate using the
following code:
CType(Me.fviewPhotoAlbum.FindControl("lnkPhotoAlbum"), LinkButton)
|
by: ChrisCicc |
last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have been able to find the cause of the problem, and will describe it here first textually and then through a code example.
The purpose of what I am trying to do is to create a postback-free web application through the use of ASP.net AJAX UpdatePanels...
|
by: .Net Sports |
last post by:
I need to dynamically assign a datalist attribute upon a helper
function receiving data from a querystring. If a user picks a certain
region, i need the datalist to display its back color, or any of its
other objects , as a certain color or css style
<HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle>
....doesnot work as a Parser error renders: Content ('<HeaderStyle
|
by: Ken Fine |
last post by:
I am using ASP.NET's CreateUserWizard control. I want to force the visitor
to use a username and e-mail address that I am providing in programming, and
I do not want the visitor to be able to edit the forms input.
I am aware that I can roll my own Create User form by using the membership
API, but I am lazy and want to use most of the CreateUserWizard control's
features.
I tried converting the form to a template and setting the UserName...
|
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...
|
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,...
| |
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |