473,614 Members | 2,351 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding data (string) to a label

Hi

I build a page that has a dropdownlist control bound with data from a
database. When user select an item from the dropdownlist I want a label to
be filled with a result from a stored procedure. The stored procedure takes
an ID of a selected item (@BoundID) from the dropdownlist and gives a result
(@BoundIdentifi er) as follows:

---
Running [dbo].[tbh_GetBoundIde ntifier] ( @BoundID =
cf44452b-8b05-45da-a7c6-14146fba0356, @BoundIdentifie r = <NULL).

No rows affected.
(0 row(s) returned)
@BoundIdentifie r = 160302_R.0582
@RETURN_VALUE = 0
Finished running [dbo].[tbh_GetBoundIde ntifier].
---

The BoundIdentifier is always 13 char long.
How can I do that? I can't find any 'binding' for a label.
I'm new to ASP.NET.

Jun 27 '08 #1
2 1866
The binding part is simple:

Label1.Text = ParamBoundIdent ifier.Value;

To work through this, you will have to create a data access routine with two
parameters.

1. Input parameter @BoundID
2. Output parameter @BoundIdentifie r

Not sure what the "always 13 chars" means, unless you are telling me the
field, in the database, is char(13), which really means very little to me.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************** *************** **************
| Think outside the box! |
*************** *************** **************
"Igor" <ig***@live.com wrote in message
news:8B******** *************** ***********@mic rosoft.com...
Hi

I build a page that has a dropdownlist control bound with data from a
database. When user select an item from the dropdownlist I want a label to
be filled with a result from a stored procedure. The stored procedure
takes an ID of a selected item (@BoundID) from the dropdownlist and gives
a result (@BoundIdentifi er) as follows:

---
Running [dbo].[tbh_GetBoundIde ntifier] ( @BoundID =
cf44452b-8b05-45da-a7c6-14146fba0356, @BoundIdentifie r = <NULL).

No rows affected.
(0 row(s) returned)
@BoundIdentifie r = 160302_R.0582
@RETURN_VALUE = 0
Finished running [dbo].[tbh_GetBoundIde ntifier].
---

The BoundIdentifier is always 13 char long.
How can I do that? I can't find any 'binding' for a label.
I'm new to ASP.NET.
Jun 27 '08 #2
Not sure if I understand.

For the dropdownlist, to bind it with a datasource, code is as follows:

<asp:DropDownLi st ID="DropDownLis t4" runat="server"
DataSourceID="O bjectDataSource 4" Enabled="False" DataTextField=" BoundName"
DataValueField= "BoundID" AppendDataBound Items="True" AutoPostBack="T rue"
OnDataBinding=" DropDownList4_D ataBinding"
OnSelectedIndex Changed="DropDo wnList4_Selecte dIndexChanged">
</asp:DropDownLis t>

<asp:ObjectData Source ID="ObjectDataS ource4" runat="server"
OldValuesParame terFormatString ="original_{ 0}"
SelectMethod="G etBounds"
TypeName="odsTa bleAdapters.tb_ BoundsTableAdap ter">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="Drop DownList3"
Name="CommuneID " PropertyName="S electedValue"
Type="Object" />
<asp:Paramete r Name="ValidFrom " Type="DateTime" />
<asp:Paramete r Name="ValidTo" Type="DateTime" />
</SelectParameter s>
</asp:ObjectDataS ource>

I wrote a stored procedure that takes to parameres (@BoundID and
@BoundIdentifie r) and based on the @BoundID makes some computation.
All I want to do (but have absolutely no clue how) is when user makes a
selection in the drop down list, take the ID of the selected value, pass it
to the stored procedure, retreive the computed value (yes, by "always 13
chars" I meant it is char(13) datatype) and place it as a text property of a
label.

I assume the code responsible for that must be placed in a
SelectedIndexCh anged property of the DropDownList4 control.

"Cowboy (Gregory A. Beamer)" <No************ @comcast.netNoS pamMwrote in
message news:A5******** *************** ***********@mic rosoft.com...
The binding part is simple:

Label1.Text = ParamBoundIdent ifier.Value;

To work through this, you will have to create a data access routine with
two parameters.

1. Input parameter @BoundID
2. Output parameter @BoundIdentifie r

Not sure what the "always 13 chars" means, unless you are telling me the
field, in the database, is char(13), which really means very little to me.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************** *************** **************
| Think outside the box! |
*************** *************** **************
"Igor" <ig***@live.com wrote in message
news:8B******** *************** ***********@mic rosoft.com...
>Hi

I build a page that has a dropdownlist control bound with data from a
database. When user select an item from the dropdownlist I want a label
to be filled with a result from a stored procedure. The stored procedure
takes an ID of a selected item (@BoundID) from the dropdownlist and gives
a result (@BoundIdentifi er) as follows:

---
Running [dbo].[tbh_GetBoundIde ntifier] ( @BoundID =
cf44452b-8b05-45da-a7c6-14146fba0356, @BoundIdentifie r = <NULL).

No rows affected.
(0 row(s) returned)
@BoundIdentifi er = 160302_R.0582
@RETURN_VALU E = 0
Finished running [dbo].[tbh_GetBoundIde ntifier].
---

The BoundIdentifier is always 13 char long.
How can I do that? I can't find any 'binding' for a label.
I'm new to ASP.NET.
Jun 27 '08 #3

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

Similar topics

2
2231
by: rmorvay | last post by:
I am trying to dynamically build a dropdownlist and bind it to a cell in a grid. I tried to utilize the following code but I am stuck at the point where I bind the dropdownlist to the grid cell. I get the following message for this code but I suspect that the " UltraWebGrid1.Rows.Cells.Value = ddlGeography;" is not how you bind the dropdownlist control to the grid. ERROR: "The type 'System.Web.UI.WebControls.DropDownList' must be...
5
4219
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
9
5324
by: Timm | last post by:
I have an ASP.NET 2.0 page with two DropDownLists. I am using declarative data binding wherever possible and trying to minimize the use of code. The list of values in DropDownList DDL2 should be (filtered) dependent upon the selection in DDL1. I think this inevitably needs some code, but I'd be happy to be told otherwise! I have some code to handle OnSelectedIndexChanged for DDL1 that sets the FilterExpression associated with the...
5
1890
by: Laura K | last post by:
I am having difficulty binding data to my datalist. The data list does not show. I have gone round and round for two days. I could really use some help looking through this code and seeing where the error is. It is usually something simple but I just can not find it!!! Any suggestion? -------------------------------------------------------------------------- My HTML code is:
0
1485
by: AM | last post by:
The following block of code defines a FormView control "FormView1" with an EditItemTemplate which has a Label and a TextBox control within it. While the Label "RequestIDLabel1" has one-way data-binding to the underlying column "RequestID", the TextBox "RequestDateTextBox" has two-way data-binding to the underlying column. If I were to generate the EditItemTemplate dynamically at runtime, and add the Label and TextBox controls at...
0
2069
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the end of this message, but I will start with an overview of the problem. I've made a content management solution for my work with a decently structured relational database system. The CMS stores articles. The CMS also stores related items --...
8
11963
by: =?Utf-8?B?QXNo?= | last post by:
Hi, I have an object, for example User. User contains various properties which i have been able to bind to successfully using wizards and the form view. However if the class User has a property which is not a string, for example a custom type Address which contains properties such as StreetAddress, City, County, Country etc how do i bind to those properties on the same form view? I have tried doing Bind("Address.StreetAddress") but...
9
2797
by: =?Utf-8?B?VGVycnk=?= | last post by:
Think it is great the way that you can set up a datsource, value member, and display member for a combobox, and map a 'code' to a 'description' and back again by binding the combobox to a datasource that contains the code. Now suppose that you want it to be read-only? That is, you have the 'code' in your DB, want the associated 'description' to display, but not let the user change it on this particular form. There is no read-only...
3
2644
by: RobertTheProgrammer | last post by:
Hi folks, I've got another problem. Basically, I'm trying to use a nested GridView, however the nexted GridView displays no values (even though in debug I'm getting valid values into my DataSet. It's probably a binding issue somewhere, but I'm not sure where. Here's the ASP (slightly edited to remove verbosity): <asp:GridView ID="GridViewMain" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" ...
0
8142
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
8640
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
8589
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...
0
7114
agi2029
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...
1
6093
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
4058
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...
0
4136
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2573
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
1757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.