error:Object reference not set to an instance of an object
<p>I used 2 gridview and I used this code behind:</p>

<pre><code>protected void SAVE_bt_Click(object sender, EventArgs e)
{
    if (Hidden_txt.Text == Convert.ToString(1))
    {

        for (int i = 0; i &lt; FirstDD_gv.Rows.Count; i++)
        {
            GridViewRow row = FirstDD_gv.Rows[i];
            bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

            if (isChecked)
            {

                SqlCommand cmd = new SqlCommand();
                cmd.Connection = new SqlConnection(Class1.CnnStr);
                cmd.CommandText = "insert into table values(@Po_Number,@Line_No,@DelDate,@First_Sec)";
                cmd.Connection.Open();
                cmd.Parameters.AddWithValue("@Po_Number", PoNumber_lbl.Text);
                cmd.Parameters.AddWithValue("@Line_No", FirstDD_gv.Rows[i].Cells[1].Text);
                cmd.Parameters.AddWithValue("@DelDate", DeliveryDate_txt.Text);
                cmd.Parameters.AddWithValue("@First_Sec", Hidden_txt.Text);
                cmd.ExecuteNonQuery();

            }
        }
    }
    else
    {

        for (int i = 0; i &lt; SecondDD_gv.Rows.Count; i++)
        {
            GridViewRow row = SecondDD_gv.Rows[i];
            bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

            if (isChecked)
            {

                SqlCommand cmd = new SqlCommand();
                cmd.Connection = new SqlConnection(Class1.CnnStr);
                cmd.CommandText = "insert into table values(@Po_Number,@Line_No,@DelDate,@First_Sec)";
                cmd.Connection.Open();
                cmd.Parameters.AddWithValue("@Po_Number", PoNumber_lbl.Text);
                cmd.Parameters.AddWithValue("@Line_No", SecondDD_gv.Rows[i].Cells[1].Text);
                cmd.Parameters.AddWithValue("@DelDate", DeliveryDate_txt.Text);
                cmd.Parameters.AddWithValue("@First_Sec", Hidden_txt.Text);
                cmd.ExecuteNonQuery();

            }
        }
    }


}
</code></pre>

<p>depends on my hidden_txt.text  that just shows one of them
when I used first gridview I don't have any problem but when I used second grid view it shows me this error:</p>

<pre><code>Object reference not set to an instance of an object
</code></pre>

<p>what should I do?</p>
