SqlConnection con=new SqlConnection (ConfigurationManager.ConnectionStrings["kumarConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataClassesDataContext db = new DataClassesDataContext(con);
//linq Table emps
var query = from emp1 in db.emps select new { emp1.id, emp1.Name };
GridView1.DataSource = query;
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
DataClassesDataContext db = new DataClassesDataContext(con);
db.Connection.Open();
//emp Name of the Table
emp empob = new emp();
empob.Name = TextBox1.Text.Trim();
db.emps.InsertOnSubmit(empob);
db.SubmitChanges();
db.Connection.Close();
TextBox1.Text = "";
}
Tuesday, March 1, 2011
Subscribe to:
Posts (Atom)