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
protected void Page_Load(objec t source,
System.Web.UI.W ebControls.Data ListCommandEven tArgs e)
{
if (Request.QueryS tring["Range"] == "Plat_Price "){
string PlatLabel = "Platino";
Label hypSelectC = (Label)e.Item.F indControl("hyp SelectC");
hypSelectC.Text = "PlatLabel" ;
}
}
And in the html I have the following label, which is contained within
a Datalist.
<ASP:DataList ID="dlListCases "
RepeatColumns=" 2"
RepeatDirection ="Horizontal "
RepeatLayout="T able" ItemStyle-CssClass="CaseR ightBorder"
runat="server">
<ItemTemplate >
<table border="0" cellpadding="0" cellspacing="0"
class="CaseTabl e">
<tr>
<td colspan="2" class="CaseTabl eHeader"><%#
DataBinder.Eval (Container.Data Item, "CaseName") %>
</td>
</tr>
<tr>
<td width="75" valign="middle" >
<asp:image runat="server" AlternateText=" Thumbnail" ImageUrl='<%#
DataBinder.Eval (Container.Data Item, "image_thum b") %>'/>
<br>
</td>
<td width="134" valign="top"> <%#
DataBinder.Eval (Container.Data Item,
"Bullet_Points" ).ToString().Re place("\n","<br >") %>
<br>
<b>Price:
<%# DataBinder.Eval (Container.Data Item, "PriceCol", "{0:c}") %>
<asp:label CssClass="BoldL abel" ID="hypSelectC "
runat="server"> </asp:label>
</b>
</td>
</tr>
</table>
</ItemTemplate>
</ASP:DataList> 3 2628
Hello Harry, 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 protected void Page_Load(objec t source, System.Web.UI.W ebControls.Data ListCommandEven tArgs e) { if (Request.QueryS tring["Range"] == "Plat_Price "){ string PlatLabel = "Platino"; Label hypSelectC = (Label)e.Item.F indControl("hyp SelectC"); hypSelectC.Text = "PlatLabel" ; } }
This is beside the point, but would help in troubleshooting your problem. Your method name in the above example is Page_Load, but the method has a signature indicative of a datalist command method. At what point are you attempting to refresh the label (ie: EditCommand, UpdateCommand, etc).
--
Matt Berther http://www.mattberther.com
Hi Matt,
I actually have two Page_Load functions.
(I am still getting my head around this bit!)
The First:
protected void Page_Load(Objec t Src, EventArgs E)
{
Lots of code here
}
I tried putting the code in this block, but it kept on chucking out
errors. (Error: CS0117 System.EventArg s does not contain a definition
for 'item')
I couldnt work out how to referance a asp:lable that is located in a
datalist on the intial page load.
Am i doing this completely the wrong way?
Any light you can shed on this would be appriciated.
Thanks
H
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Hello Harry, I couldnt work out how to referance a asp:lable that is located in a datalist on the intial page load.
First of all, in your Page_Load, you'll want to do something like this:
protected void Page_Load(objec t sender, EventArgs e)
{
if (!Page.IsPostBa ck)
{
// hook up your datalist's datasource and bind it
datalist.DataSo urce = whatever;
datalist.DataBi nd();
}
// The rest of your code
}
and then handle the datalist's ItemDataBound event via something like this:
protected void DataList_ItemDa taBound(object sender, DataListItemEve ntArgs e)
{
// this is where you would put the stuff for populating the label
}
Make sure that you've hooked up the event handler through the designer (via the properties window for the DataList) or programmaticall y in the code.
--
Matt Berther http://www.mattberther.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
Hi,
I am setting the NumericUpDown .Value property and the ValueChanged event
is NOT being fired. Does this ONLY get fired when I change it on the UI and
not programatically?
Thanks
|
by: mjw |
last post by:
I am new to VB.Net 2005 and would like to thank anybody in advance who
may help me out.
In my windows form application I am using a BindingNavagator tool strip
to display values of my database fields which are bound to my
tablesBindingSource. This works fine. What I need to do when I select
the new data row entry from the tool strip is pass one of the fields a
text field value from another TextBox on the page. I cannot get this to
|
by: John |
last post by:
Hi all, I thought that this would be very basic. Basically, I have a textbox
set at type password. When I try to set the value of this textbox at runtime
the text field does not get populated.
I thought I could just go
=========
txtPassword.Text = "MyPassword"
=========
If I do this, nothing appears in the textbox at all.
|
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: Steve Letford |
last post by:
Hi,
I'm parsing every Button / Label / hyperlink that is on my web forms so that
I can look at the text values and translate them. I used to do this in
VB.Net by casting everything as an object (Adapting the page inheritance
model by Johathon Goodyear):
As shown:
CType(myControl, Object).text = TranslatedVersion(CType(myControl,
Object).text)
| |
by: Dipendra Darbar via DotNetMonster.com |
last post by:
Hi,
I have created an AssetTracking database in SQL Server 2000 and one of my
master tables generates an autonumber for a unique PC Make. For example my
table will consist of the following:
1 HP
2 Dell
3 Fujitsu
|
by: swarnap |
last post by:
I have a control on me screen of type <FILE>. I want to set some value to that object from the database. I tried the following code using html.
<html >
<head>
<script type="text/javascript">
function fun()
{
document.getElementById('j').value="hi"
alert(document.getElementById('j').value);
|
by: Brad Pears |
last post by:
I have something strange going on - pretty sure it used to work before - and
now it does not...
Why does the following code not clear a combo box?
Me.cboLocation.Text = String.Empty
OR
Me.cboLocation.Text = ""
|
by: roguetexan |
last post by:
I have over 1000 records in a table (Context_Tasks_DB), one field of which (termed Purpose) should really be a Lookup to another table (tblPurpose), but currently simply has text (only 30 unique text values are in that field and are therefore repeated...).
I have created a table called tblPurpose with the desired, unique, lookup values (30 unique values).
I have created a NEW field called PurposeNew that references the Lookup table.
I...
|
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: 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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: 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...
| |