protected void Page_Load(object sender, EventArgs e) { var st = from s in db.ITEMMs select s; gvw_employees.DataSource = st; gvw_employees.DataBind(); } DataClasses1DataContext db = new DataClasses1DataContext();
protected void Button1_Click(object sender, EventArgs e) { try { //foreach (GridViewRow dg in gvw_employees.Rows) // { // CheckBox ckbox; // ckbox = ((CheckBox)dg.FindControl("checkBox")); // if (ckbox.Checked == true) // {
for (int i = 0; i < gvw_employees.Rows.Count; i++) {
int Id = Convert.ToInt32(gvw_employees.Rows[i].Cells[0].Text);
string name = gvw_employees.Rows[i].Cells[1].Text; int qty = Convert.ToInt32(gvw_employees.Rows[i].Cells[2].Text); decimal amt = Convert.ToDecimal(gvw_employees.Rows[i].Cells[3].Text); var st = new ITEMM { ID = Id, namw = name.ToString(), qty = qty, amount = amt,
}; db.ITEMMs.InsertOnSubmit(st); db.SubmitChanges(); Label1.Text = "success"; } //} //else //{ // Label1.Text = "faiels"; //}
//} } catch (Exception ex) { Label1.Text = ex.Message.ToString(); } }
Attachment: sent.zip