putting data in a label without using gridview, repeater etc ..

Discussion in 'ASP .Net' started by Eric, Feb 15, 2009.

  1. Eric

    Eric Guest

    Hi,

    i was wondering whether it's possible to get some data from a table and to
    put it directly in a label without using gridview, reapeater, detailsview
    etc ...

    Here what i tried (doen't work): (this query returns only one record)

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:myconn %>"
    SelectCommand="SELECT [n1] FROM [mytable]"></asp:SqlDataSource>
    <asp:Label ID="Label1" runat="server" Text='<%# Eval("n1")
    %>'></asp:Label>
    ....

    Thanks
    Eric
    Eric, Feb 15, 2009
    #1
    1. Advertising

  2. Do you want to do it that way or in code? In code would of course be easy,
    just set a Variable to the result of ExecuteScalar (your sql) and:
    Label1.Text = Variable

    Justin.

    "Eric" <> wrote in message
    news:...
    > Hi,
    >
    > i was wondering whether it's possible to get some data from a table and to
    > put it directly in a label without using gridview, reapeater, detailsview
    > etc ...
    >
    > Here what i tried (doen't work): (this query returns only one record)
    >
    > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > ConnectionString="<%$ ConnectionStrings:myconn %>"
    > SelectCommand="SELECT [n1] FROM [mytable]"></asp:SqlDataSource>
    > <asp:Label ID="Label1" runat="server" Text='<%# Eval("n1")
    > %>'></asp:Label>
    > ...
    >
    > Thanks
    > Eric
    >
    >
    Justin Dutoit, Feb 16, 2009
    #2
    1. Advertising

  3. Eric

    Eric Guest

    Hi thanks for replying.
    I know how to do it in code, but what i want to know is: is it possible to
    do that in the aspx file, without code?
    Thanks

    "Justin Dutoit" <> schreef in bericht
    news:...
    > Do you want to do it that way or in code? In code would of course be easy,
    > just set a Variable to the result of ExecuteScalar (your sql) and:
    > Label1.Text = Variable
    >
    > Justin.
    >
    > "Eric" <> wrote in message
    > news:...
    >> Hi,
    >>
    >> i was wondering whether it's possible to get some data from a table and
    >> to put it directly in a label without using gridview, reapeater,
    >> detailsview etc ...
    >>
    >> Here what i tried (doen't work): (this query returns only one record)
    >>
    >> <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    >> ConnectionString="<%$ ConnectionStrings:myconn %>"
    >> SelectCommand="SELECT [n1] FROM
    >> [mytable]"></asp:SqlDataSource>
    >> <asp:Label ID="Label1" runat="server" Text='<%# Eval("n1")
    >> %>'></asp:Label>
    >> ...
    >>
    >> Thanks
    >> Eric
    >>
    >>

    >
    >
    Eric, Feb 16, 2009
    #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. Neo Geshel
    Replies:
    2
    Views:
    726
    Neo Geshel
    Nov 17, 2005
  2. Saurabh
    Replies:
    6
    Views:
    4,517
    Chris Smith
    May 30, 2004
  3. Replies:
    2
    Views:
    2,579
  4. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    383
    Fredrik Lundh
    Aug 13, 2008
  5. Knut Krueger
    Replies:
    8
    Views:
    262
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page