Saturday, July 4, 2009

LINQ Insert Records - ASP.NET

country table
COUNTRY_NAME nvarchar(80)
COUNTRY_SHORT_NAME nchar(3)
COUNTRY_SORT_ORDER float
COUNTRY_VALID bit
code behind page
protected void Button1_Click(object sender, EventArgs e)
{
ShoppingDataContext db = new ShoppingDataContext();
ECM_COUNTRY objCountry = new ECM_COUNTRY
{
COUNTRY_NAME =txtCountryName.Text.Trim(),
COUNTRY_SHORT_NAME=txtshortName.Text.Trim(),
COUNTRY_SORT_ORDER =Convert.ToDouble(txtSortOrder.Text.Trim()),
COUNTRY_VALID =Convert.ToBoolean(chkIsActive.Checked)
};
db.ECM_COUNTRies.InsertOnSubmit(objCountry);
db.SubmitChanges();
Response.Redirect(Request.RawUrl);
txtCountryName.Text = "";
txtshortName.Text = "";
txtSortOrder.Text = "";
chkIsActive.Checked = false;
}

No comments:

Post a Comment

http://blogsiteslist.com