Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Binding data (string) to a label

Reply
Thread Tools

Binding data (string) to a label

 
 
Igor
Guest
Posts: n/a
 
      06-13-2008
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
(@BoundIdentifier) as follows:

---
Running [dbo].[tbh_GetBoundIdentifier] ( @BoundID =
cf44452b-8b05-45da-a7c6-14146fba0356, @BoundIdentifier = <NULL> ).

No rows affected.
(0 row(s) returned)
@BoundIdentifier = 160302_R.0582
@RETURN_VALUE = 0
Finished running [dbo].[tbh_GetBoundIdentifier].
---

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.

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      06-13-2008
The binding part is simple:

Label1.Text = ParamBoundIdentifier.Value;

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

1. Input parameter @BoundID
2. Output parameter @BoundIdentifier

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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 (@BoundIdentifier) as follows:
>
> ---
> Running [dbo].[tbh_GetBoundIdentifier] ( @BoundID =
> cf44452b-8b05-45da-a7c6-14146fba0356, @BoundIdentifier = <NULL> ).
>
> No rows affected.
> (0 row(s) returned)
> @BoundIdentifier = 160302_R.0582
> @RETURN_VALUE = 0
> Finished running [dbo].[tbh_GetBoundIdentifier].
> ---
>
> 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.


 
Reply With Quote
 
 
 
 
Igor
Guest
Posts: n/a
 
      06-13-2008
Not sure if I understand.

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

<aspropDownList ID="DropDownList4" runat="server"
DataSourceID="ObjectDataSource4" Enabled="False" DataTextField="BoundName"
DataValueField="BoundID" AppendDataBoundItems="True" AutoPostBack="True"
OnDataBinding="DropDownList4_DataBinding"
OnSelectedIndexChanged="DropDownList4_SelectedInde xChanged">
</aspropDownList>

<asp:ObjectDataSource ID="ObjectDataSource4" runat="server"
OldValuesParameterFormatString="original_{0}"
SelectMethod="GetBounds"
TypeName="odsTableAdapters.tb_BoundsTableAdapter">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList3"
Name="CommuneID" PropertyName="SelectedValue"
Type="Object" />
<asparameter Name="ValidFrom" Type="DateTime" />
<asparameter Name="ValidTo" Type="DateTime" />
</SelectParameters>
</asp:ObjectDataSource>

I wrote a stored procedure that takes to parameres (@BoundID and
@BoundIdentifier) 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
SelectedIndexChanged property of the DropDownList4 control.



"Cowboy (Gregory A. Beamer)" <(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> The binding part is simple:
>
> Label1.Text = ParamBoundIdentifier.Value;
>
> To work through this, you will have to create a data access routine with
> two parameters.
>
> 1. Input parameter @BoundID
> 2. Output parameter @BoundIdentifier
>
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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 (@BoundIdentifier) as follows:
>>
>> ---
>> Running [dbo].[tbh_GetBoundIdentifier] ( @BoundID =
>> cf44452b-8b05-45da-a7c6-14146fba0356, @BoundIdentifier = <NULL> ).
>>
>> No rows affected.
>> (0 row(s) returned)
>> @BoundIdentifier = 160302_R.0582
>> @RETURN_VALUE = 0
>> Finished running [dbo].[tbh_GetBoundIdentifier].
>> ---
>>
>> 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.

>


 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner ASP .Net 0 04-09-2007 09:00 PM
Complex data binding question, binding child objects of a custom collection. JcFx ASP .Net Datagrid Control 0 06-01-2005 04:01 PM
Data Binding - using inline code vs. functions vs. straight binding Jordan ASP .Net 2 02-10-2004 08:32 PM
data binding in label field Grey ASP .Net 2 01-14-2004 01:44 PM
Use label and ViewState with data binding funciton Grey ASP .Net Building Controls 0 01-14-2004 12:53 PM



Advertisments