I used the autoGenerateEditButton function of gridview.
protected void Page_Load(object sender, EventArgs e)
{
viewgrid.AutoGenerateEditButton = true;
viewgrid.RowEditing += new GridViewEditEventHandler(viewTable_RowEditing);
}
void viewTable_RowEditing(object sender, GridViewEditEventArgs e)
{
viewTable.EditIndex = e.NewEditIndex;
filldata();
}