Thursday, November 12, 2009

Linq Sumbit

protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
DataClassesDataContext dataContextAdd = new DataClassesDataContext(ConfigurationManager.ConnectionStrings["ConnRootDataBase"].ConnectionString);

MemberYear memberYear = new MemberYear
{
MemberYearId = GenerateID(),
ProfileId = Convert.ToInt64(drpMember.SelectedValue),
GeographicId = Convert.ToInt64(drpConstituency.SelectedValue),
ElectionYearId = Convert.ToInt64(drpElectionYear.SelectedValue)

};
dataContextAdd.MemberYears.InsertOnSubmit(memberYear);
dataContextAdd.SubmitChanges();
dataContextAdd.Dispose();
lblError.Text = "your Information Inserted Succesfully!!";
lblError.ForeColor = System.Drawing.Color.Green;
}
catch (Exception ex)
{
lblError.Text = ex.Message.ToString();
}


}

No comments:

Post a Comment