Binding data (string) to a label

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Igor

    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.

  • Cowboy \(Gregory A. Beamer\)

    #2
    Re: Binding data (string) to a label

    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


    or just read it:


    *************** *************** **************
    | Think outside the box! |
    *************** *************** **************
    "Igor" <igorm@live.com wrote in message
    news:8B84B633-516F-431F-B2D2-16DB328C77EE@mi crosoft.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.

    Comment

    • Igor

      #3
      Re: Binding data (string) to a label

      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)" <NoSpamMgbworld @comcast.netNoS pamMwrote in
      message news:A5393B68-DE50-4BA3-A9D5-7116174878D1@mi crosoft.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

      >
      or just read it:

      >
      *************** *************** **************
      | Think outside the box! |
      *************** *************** **************
      "Igor" <igorm@live.com wrote in message
      news:8B84B633-516F-431F-B2D2-16DB328C77EE@mi crosoft.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.
      >

      Comment

      Working...