Re: HTML Output Databinding

  •  07-23-2008, 9:10 AM

    Re: HTML Output Databinding

     
    I have not tried databinding automatically, but you could easily push the data around using the Edtiro1.Text property as Adam points out...
     
    C# Code Example 
     
    // post the following into your ASPX page inside <% %> or in the page_load call in the code-behind.  This is really a mickey-mouse example but hopefully it gives you an idea of what to do.  When you click the SAVE button in the editor, the page will post back and the html is retreived from the Editor1.Text propery.
     
    if (Page.IsPostBack)
    {
      // Create database connection (conn string is an example here)
      System.Data.SqlClient.SqlConnection conn
              =
    new System.Data.SqlClient.SqlConnection(@"Sever=(local)\SQLEXPRESS; Database=Blah");
      conn.Open();
      // Create command
      System.Data.SqlClient.SqlCommand sql = new System.Data.SqlClient.SqlCommand("spInsertHtml", conn);
      sql.CommandType = System.Data.
    CommandType.StoredProcedure;
      sql.Connection = conn;
      // Set editor html to parameter
      System.Data.SqlClient.SqlParameter param1 = new System.Data.SqlClient.SqlParameter();
      param1.ParameterName =
    "@HTML";
      param1.SqlDbType = System.Data.
    SqlDbType.Text;
      param1.Value = Editor1.Text;
      sql.Parameters.Add(param1);
      // Run query
      string id = sql.ExecuteScalar().ToString();
      // Close connection
      conn.Close();
    }
     
    SQL Server Stored Procedure Used in the above
     
      

    CREATE PROCEDURE spInsertHtml @HTML TEXT
    AS

    -- Insert HTML into table, merely and example here
    INSERT INTO MY_HTML_TABLE
    (
        HTML
    )
    VALUES
    (
        @HTML
    )
    -- Return Identity from new table row
    SELECT @@IDENTITY

View Complete Thread