Search This Blog

10 February 2011

GridView Insertion


// coding in gridview.aspx source file //



// coding in gridview.aspx.cs file //

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
TextBox txtNewName = (TextBox)grd.FooterRow.FindControl("txtNewName");
TextBox t1 = (TextBox)grd.FooterRow.FindControl("txtid");
c.cmd.CommandText = "select * from emp";
c.adp.Fill(c.ds, "st");
c.dr = c.ds.Tables["st"].NewRow();
c.dr["empid"] = t1.Text;
c.dr["empname"] = txtNewName.Text;
c.ds.Tables["st"].Rows.Add(c.dr);
c.scb = new System.Data.SqlClient.SqlCommandBuilder(c.adp);
c.adp.Update(c.ds.Tables["st"]);
bind();
}
}


No comments:

Post a Comment