Trying to fetch values on gridview
<p>I am trying to fetch values on a GridView with the following code:</p>

<pre><code>protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    GridViewRow row = GridView1.SelectedRow;
    string Username = row.Cells[3].Text;
    string Password = row.Cells[4].Text;
    string Email = row.Cells[5].Text;
    string ID_Inscricao = row.Cells[1].Text;
    SqlConnection sqlConn = new SqlConnection(
        ConfigurationManager.ConnectionStrings["FormacaoConnectionString"].ToString());
    SqlCommand sqlComm = new SqlCommand();

    sqlComm = sqlConn.CreateCommand();
    sqlComm.Parameters.Add("@Username", SqlDbType.Text);
    sqlComm.Parameters.Add("@Password", SqlDbType.Text);
    sqlComm.Parameters.Add("@Email", SqlDbType.Text);
    sqlComm.Parameters.Add("@ID_Inscricao", SqlDbType.Text);

    sqlComm.Parameters["@Username"].Value = Username;
    sqlComm.Parameters["@Password"].Value = Password;
    sqlComm.Parameters["@Email"].Value = Email;
    sqlComm.Parameters["@ID_Inscricao"].Value = ID_Inscricao;
    string sql = "INSERT INTO Utilizadores " +
        "(Username, Password, Email,ID_Inscricao) " +
        "VALUES (@Username, @Password, @Email, @ID_Inscricao)";
    sqlComm.CommandText = sql;
    sqlConn.Open();
    sqlComm.ExecuteNonQuery();
    sqlConn.Close();
}
</code></pre>

<p>So, the problem is I can't get the values from the GridView, but instead get a "NullReferenceException was unhandled by user code". Can anybody tell me what I'm doing wrong?</p>

<p>Best regards</p>
