Get Data from ConnectionString in a function

Last post 05-17-2008 3:24 AM by caspar.net. 5 replies.

Sort Posts:

  • Get Data from ConnectionString in a function

    05-16-2008, 8:44 AM
    • Loading...
    • caspar.net
    • Joined on 04-19-2008, 5:57 AM
    • Posts 26

     Hallo,

     I am new in ASP.NET, i work with VisualWebDeveloper Express 2008 and its very nice an komfortible.

    I have a Database and a DatabaseConnection, i can show the Data in a Label (Text='<%# Eval("price") %>')

    But now i want to format the string from the database and do something like this: string.Format("{0:c}",Wert)

    Now my question: to format the string i have to get the item from the database (in this case <%# Eval("price") %>) in the codeBehind Area

    for example: Dim wert as String = price

    What do i have to do, to get this specific item from the ConnectionString

    thanks for any help 

    caspar.net

    is there any tutorial that shows me how to handle data from a connectionString 

  • Re: Get Data from ConnectionString in a function

    05-16-2008, 9:00 AM
    Answer

    You can acutally format the string right in the Eval, take a look at this page: http://msdn.microsoft.com/en-us/library/2d76z3ck.aspx

    Basically you can do Text='<%#Eval("price", "{0:c}") %>'

    Please remember to click "Mark as Answer" on this post if it helped you.
  • Re: Get Data from ConnectionString in a function

    05-16-2008, 9:00 AM
    Answer
    • Loading...
    • Jeev
    • Joined on 11-24-2005, 7:49 AM
    • Posts 3,112

    Please take a look at some of the data access tutorial on this website. This should give you an idea on what needs to be done For formatting use this syntax

    Eval("price","{0:c}")

    Jeev
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If you get the answer to your question, please mark it as the answer.
  • Re: Get Data from ConnectionString in a function

    05-16-2008, 9:04 AM
    Answer
    • Loading...
    • anas
    • Joined on 09-21-2006, 8:31 AM
    • Jerusalem
    • Posts 4,069

    caspar.net:
    Now my question: to format the string i have to get the item from the database (in this case <%# Eval("price") %>) in the codeBehind Area

    No, you can use inline formating as follows:

    <asp:Label id=... Text='<%# Eval("price","{0:c}") %>' .......

     

    Best Regards,

    Anas Ghanem| LogFile
  • Re: Get Data from ConnectionString in a function

    05-16-2008, 9:23 AM
    Answer

     Try this code:

     
    <%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>
    
     
     
    Mark as Answer if the post was useful to you

    Rajesh Thangarasu
    Microsoft Certified Professional
  • Re: Get Data from ConnectionString in a function

    05-17-2008, 3:24 AM
    • Loading...
    • caspar.net
    • Joined on 04-19-2008, 5:57 AM
    • Posts 26

    Thank you all, it works very nice

     caspar.net

     Germany, EU
     

Page 1 of 1 (6 items)
Microsoft Communities
Page view counter