Hi.. im getting errors in this asp.net code.. im trying to store this object to the

Emc

New member
data base but it dont work? using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
// more...
using Lab5Model;

public partial class ui_uc_BlogEditorVersion1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{

} // Page_Load

// Add a new post
protected void btnPost_Click(object sender, EventArgs e)
{
// Try to add the post
try
{
using (var context = new Lab5ModelContainer())
{
// Configure a new post
Post newPost = new Post();
newPost.title = tbTitle.Text.Trim();
newPost.dateCreated = DateTime.Now;
newPost.author = "Mchavez";
newPost.publishStatus = "Published";
newPost.visibilityStatus = rblVisibility.SelectedItem.Text;
newPost.content = tbPost.Text.Trim();


// Add the post
//context.AddObject(newPost);

//context.Lab5Post.i(1, tbTitle.Text.Trim(), DateTime.Now, "Mchavez", "Published", rblVisibility.SelectedItem.Text, tbPost.Text.Trim());

//context.SaveChanges();

// Update the user
lblPostResult.ForeColor = System.Drawing.Color.Green;
lblPostResult.Text = "A new post has been added";

// Clear the fields
tbTitle.Text = tbSynopsis.Text = tbSlug.Text = tbPost.Text = "";
rblComments.SelectedIndex = rblVisibility.SelectedIndex = 1;
ddlCategory.SelectedIndex = 0;

// Update the ListView

}
}
catch (Exception ex)
{
lblPostResult.ForeColor = System.Drawing.Color.Red;
lblPostResult.Text = ex.Message + " " + ex.InnerException.Message;
}

} // btnPost_Click

}
 
Back
Top