I want to delete record from database in listview
<p>I keep getting the error Object reference not set to an instance of an object in line 
<code>dCmd.Parameters.Add("@ID", tID.Text.Trim());</code>. I want to delete a record from <code>listview</code> in database. My code is:</p>

<pre><code>protected void DeleteListViewItem(object sender, ListViewDeleteEventArgs e)
{
    ListViewItem item = lstOrigin.Items[e.ItemIndex];

    //TextBox tID = (TextBox)item.FindControl("txtID");
    TextBox tID = (TextBox)(lstOrigin.Items[e.ItemIndex].FindControl("txtID"));

    // insert records into database
    SqlConnection conn = new SqlConnection("Data Source=ST0022;Initial Catalog=QuickMove_Globe;Persist Security Info=True;User ID=sa;Password=good");

    string Sql = "delete from Origin where ID = @ID";
    conn.Open();
    SqlCommand dCmd = new SqlCommand(Sql, conn);

    dCmd.Parameters.Add("@ID", tID.Text.Trim());
    dCmd.ExecuteNonQuery();

    conn.Close();

    // Rebind the details
    BindPersonDetails("Address ASC");
    lstOrigin.EditIndex = -1;
}
</code></pre>
