Get the grid view count then implement the below code
protected void GridView1_RowCommand
(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Add")
{
string strFirstName = ((TextBox)
GridView1.FooterRow.FindControl("txtFname")).Text;
string strLastName =
((TextBox)GridView1.FooterRow.FindControl
("txtLname")).Text;
string strDepartment =
((TextBox)GridView1.FooterRow.FindControl
("txtDept")).Text;
string strLocation = ((TextBox)GridView1.FooterRow.
FindControl("txtLoc")).Text;
SqlDataSource1.InsertParameters["fieldname"].DefaultValue
= strFirstName;
SqlDataSource1.InsertParameters["fieldname"].DefaultValue
= strLastName;
SqlDataSource1.InsertParameters["fieldname"].DefaultValue
= strDepartment;
SqlDataSource1.InsertParameters["fieldname"].DefaultValue
= strLocation;<b></b>
SqlDataSource1.Insert();
}
}