Binding data (string) to a label

Discussion in 'ASP .Net' started by Igor, Jun 13, 2008.

  1. Igor

    Igor Guest

    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.
     
    Igor, Jun 13, 2008
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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.
     
    Cowboy \(Gregory A. Beamer\), Jun 13, 2008
    #2
    1. Advertising

  3. Igor

    Igor Guest

    Not sure if I understand.

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

    <asp:DropDownList ID="DropDownList4" runat="server"
    DataSourceID="ObjectDataSource4" Enabled="False" DataTextField="BoundName"
    DataValueField="BoundID" AppendDataBoundItems="True" AutoPostBack="True"
    OnDataBinding="DropDownList4_DataBinding"
    OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged">
    </asp:DropDownList>

    <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" />
    <asp:parameter Name="ValidFrom" Type="DateTime" />
    <asp:parameter 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)" <> wrote in
    message news:...
    > 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" <> wrote in message
    > news:...
    >> 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.

    >
     
    Igor, Jun 13, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grey

    data binding in label field

    Grey, Jan 14, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    474
    Michael
    Jan 14, 2004
  2. Jordan
    Replies:
    2
    Views:
    2,539
    Jordan
    Feb 10, 2004
  3. CSharpner
    Replies:
    0
    Views:
    1,060
    CSharpner
    Apr 9, 2007
  4. Grey

    Use label and ViewState with data binding funciton

    Grey, Jan 14, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    125
  5. Knut Krueger
    Replies:
    8
    Views:
    282
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page