473,624 Members | 2,232 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting multiple property values in one databind

If I have aspx code like:

< asp:label Text='<%# GetData() %>'>< /asp:label>

Is there some way in my GetData() method that I can get a handle to this
Label control, and set other properties apart from Text, too??

That way a single db addess could set text, color, visibility etc.

Passing 'this' just returns the asp:Page control :(

Thanks,

John

PS. I may have asked this before, but can't find the message anywhere!
Nov 18 '05 #1
2 1354
"John" <js************ @ecclesdeleteth iscollege.ac.uk > wrote in message
news:u8******** ******@TK2MSFTN GP10.phx.gbl...
If I have aspx code like:

< asp:label Text='<%# GetData() %>'>< /asp:label>

Is there some way in my GetData() method that I can get a handle to this
Label control, and set other properties apart from Text, too??


It wouldn't be a good idea for GetData to know what control it's binding to,
so it wouldn't be a good idea for it to set any properties at all, much less
to set more than one property.

What about:

<asp:Label Text='<%# GetData()["Text"] %>' ForeColor='<%# GetData["Color"]
%>' />
--
John Saunders
johnwsaundersii i at hotmail
Nov 18 '05 #2
John,

Yes you can do this, and it is perfectly ok.

Add DataBinding event to your Label control and make GetData () the event
handler. It will get parameter "sender" which is the reference to the
control originated the event. In this way you can use the same GetData()
method for many controls and access as many control properties as you wish.

Eliyahu

The trick
"John" <js************ @ecclesdeleteth iscollege.ac.uk > wrote in message
news:u8******** ******@TK2MSFTN GP10.phx.gbl...
If I have aspx code like:

< asp:label Text='<%# GetData() %>'>< /asp:label>

Is there some way in my GetData() method that I can get a handle to this
Label control, and set other properties apart from Text, too??

That way a single db addess could set text, color, visibility etc.

Passing 'this' just returns the asp:Page control :(

Thanks,

John

PS. I may have asked this before, but can't find the message anywhere!

Nov 18 '05 #3

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

Similar topics

6
1523
by: suzy | last post by:
hello, how can i have multiple datarepeaters on the same aspx page? i have tried something similar to this: <asp:repeater id="repeater1" runat="server"> <itemtemplate> <td>text</td> </itemtemplate>
2
7389
by: Thomas Solh?j | last post by:
Hi all. I cant databind rtf values to the rtf property of a winform richtextbox control. Does something have a clue how this i done? Ive tried this without luck: this.richTextBox1.DataBindings.Add(new System.Windows.Forms.Binding("Rtf", this.dataSet1, "rftdescription")); Its no trouble doing it the the Text property with text values like
9
2334
by: james.e.coleman | last post by:
Hello, I have created a custom dropdownlist that is used multiple times within a single page. When trying to set the values of the controls with the page in which they are being used, they all are set to the value of the last control. I found this link: http://www.codecomments.com/archive315-2005-1-366113.html which I think explains the situation but I'm not sure how to implement the solution in my case since I am not using a .ascx...
8
2257
by: David Lozzi | last post by:
Howdy, I have a user control that is a report to display data. On the page the control is inserted in, I have filter options to filter the report. When I try to do something like this, nothing happens. dim filt as string ... build filter string... UserControl.ReportFilter = filt
0
942
by: WB | last post by:
Hi, I have a ListBox on a web page that allows user to select their favorite colors. They can select multiple colors by pressing the Ctrl or Shift button on the keyboard. Now when user come back to edit their profile, this list box is supposed to highlight the multiple colors that they have selected. But how do I set multiple values for the .SelectedValue property? For your info, I have a helper class that return a DataSet of all the...
1
1399
by: Waran | last post by:
How to bind Multiple results into a datagrid. For example Assume the values for dsCustCode.Tables(0).Rows.Count = 4,and the values are "'Val1','val2','val3','val4'" in the below loop In the above situation four datasource needs to be bind in the grid. I know the below is binding the last value's (Val4) datasource in the DataGrid For iCountCustCode = 0 To dsCustCode.Tables(0).Rows.Count - 1 CusCode =
2
1116
by: Martin Gregersen | last post by:
Hi Looking for a way to bind a readonly property on a textbox to a parameter, not having to cycle through all controls, but rather setting <textbox id="myTextbox" readonly="<%# SetReadOnly %where SetReadOnly is a public property, saved to a Session variable. Can't get it to work, eventhough the designer shows and says that it is databound... When I debug I can see that it never accesses the property, as if it just says 'Okay, the...
3
5480
by: oliviers | last post by:
Here is my scenario: I first create a base class with one property : public class MyControl inherits System.Web.UI.UserControl Public readonly property IsEditable() boolean Get Return False '(More code later) End Get End property End Class
1
3057
by: dhyder | last post by:
OK, like the title says my error is Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. I have looked into this a lot, but have not been able to find a solution to it. <%@ Page Language="c#" runat="server" debug="true" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %> <script runat="server"> OleDbConnection conn = new...
0
8177
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
8681
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
8488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6112
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
5570
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();...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
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
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
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.