Try below code:
protected void grdvwParts_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
int id = Convert.ToInt32(e.CommandArgument);
if (e.CommandName.Equals("EditRecord"))
{
string CustomerID = ((Label)GridView1.Rows[e.RowIndex]
.FindControl("lblCustomerID")).Text;
string Name = ((TextBox)GridView1.Rows[e.RowIndex]
.FindControl("txtContactName")).Text;
string Company = ((TextBox)GridView1.Rows[e.RowIndex]
.FindControl("txtCompany")).Text;
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "update customers set ContactName=@ContactName," +
"CompanyName=@CompanyName where CustomerID=@CustomerID;" +
"select CustomerID,ContactName,CompanyName from customers";
}
}
}
Here it is fetching value from lblCustomerID and others - so you need to change as per your page control ID.