I heard the same error from many of the developers. The main reason for this error is
gridview may not
bind (load) its values before fetching the records.. So first
bind(load) the gridview controls before accessing its values..
This will applicable for DataList's, drop downlists, checkboxlists, radiobuttonlists etc... If you bind all these controls before fetching its values you may not come accross with the same error..
Try below..
protected void Page_Load(object sender, EventArgs e)
{
if (this.Page.PreviousPage != null)
{
GridView GridView1 = (GridView)this.Page.PreviousPage.FindControl("GridView1");
GridView1.DataBind();
GridViewRow selectedRow = GridView1.SelectedRow;
txtStoreID.Text = selectedRow.Cells[1].Text;
txtStoreName.Text = selectedRow.Cells[2].Text;
txtStoreOwner.Text = selectedRow.Cells[3].Text;
txtAddress.Text = selectedRow.Cells[4].Text;
txtContactNumber.Text = selectedRow.Cells[5].Text;
txtRoute.Text = selectedRow.Cells[6].Text;
txtStatus.Text = selectedRow.Cells[7].Text;
}
}
...