Use Selected ID in DetailView as Parameter
<p>If i find the 3 "Yes" in my table for a given ID then i am sending an email. So as you can see the code below is using the querystring as parameter and using that in my select statement but what i want to do is use the selected ID in the DetailView instead of the query-string.  Here is the code that uses the query-sting:</p>

<pre><code>protected void Check_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
    {


        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);

        SqlCommand cmd = new SqlCommand("SELECT count(*) from MyTable WHERE ID =@ID And (field1='Yes' And field2='Yes' And field3='Yes')", con);
        cmd.Parameters.Add("@ID", Request.QueryString["ID"]);
        cmd.Connection = con;
        con.Open();
        int result = (int)cmd.ExecuteScalar();

        if (result == 1)
        {
           send email...
        } 
</code></pre>

<p>and here is the updated code that i modified and tried to use the DetailView ID but does not work properly, what am i doing wrong here pls help:</p>

<pre><code> protected void Check_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
    {

        string ID = Detailview1.Rows[0].Cells[1].Text;
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);
        SqlCommand cmd = new SqlCommand("SELECT count(*) from MyTable WHERE ID =@ID And (field1='Yes' And field2='Yes' And field3='Yes')", con);
        cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = ID;

        cmd.Connection = con;
        con.Open();
        int result =(int) cmd.ExecuteScalar();

        if (result == 1)
        {
        send email...
        }
</code></pre>
