Control's default text from database

Last post 02-18-2004, 5:16 PM by Adam. 3 replies.
Sort Posts: Previous Next
  •  02-17-2004, 6:19 AM 386

    Control's default text from database

    How do I set the default text of the control, with data from a record from a database? It's easy enough to set default text via the Text property, but how on earth do I take this text from a database (for instance, for a "Edit post" function in a forum or similar)?

     

    Before, when I used a regular Textarea, it was easy enough to just use:

     

    <textarea cols="30" rows="7" name="text"><%=objDataR("text")%></textarea>

     

    (of course after opening a database connection and a ExecuteReader). But ASP.NET doesn't allow server tags (<% %>) as part of a server control, so how do I solve this with CuteEditor with the least amount of work?

     

  •  02-17-2004, 7:34 AM 389 in reply to 386

    Re: Control's default text from database

    In your codebehind or server side code, just retrieve your data from the DB and add it to the cuteeditor1.text property, done.

     

     

  •  02-18-2004, 5:05 AM 392 in reply to 389

    Re: Control's default text from database

    The problem is that I, for this page, displays all other database information via server tags (<% %>), so I don't have any Page_Load subroutine or similar...

     

    Is there any work-around to get around that, or do I need to start modifying the whole page in order to set that property from Page_Load or similar?

     

  •  02-18-2004, 5:16 PM 395 in reply to 392

    Re: Control's default text from database

     Daniel,

     

    You can populate the control with data from your database in the Page_Load.

     

    <script runat="server">

    string DataFromYourDataBase;

     

    void Page_Load(object sender, System.EventArgs e){

         if (!IsPostBack){

            Literal1.Text = DataFromYourDataBase;

       }

    </script>


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View as RSS news feed in XML