Delete comment accordingly to whether the current user is the one who posted the comment in ListView
<p>How do i delete the comment accordingly to the user that post that particular comment using ListView? I have added a button and make it Visible false so that in my .cs code when i checked that the current login user is the one who posted the comment, the delete button will be visible. Currently, i tried this:</p>

<pre><code>protected void PostCommentButton_Click(object sender, EventArgs e)
{
    if (!Page.IsValid)
        return;


    MembershipUser currentUser = Membership.GetUser();
    Guid currentUserId = (Guid)currentUser.ProviderUserKey;


    string connectionString = ConfigurationManager.ConnectionStrings["CommentConnectionString"].ConnectionString;
    string insertSql = "INSERT INTO Comments(Subject, Body, UserId) VALUES(@Subject, @Body, @UserId)";

    using (SqlConnection myConnection = new SqlConnection(connectionString))
    {
        myConnection.Open();

        SqlCommand myCommand = new SqlCommand(insertSql, myConnection);
        myCommand.Parameters.AddWithValue("@Subject", Subject.Text.Trim());
        myCommand.Parameters.AddWithValue("@Body", Body.Text.Trim());
        myCommand.Parameters.AddWithValue("@UserId", currentUserId);

        myCommand.ExecuteNonQuery();

        myConnection.Close();

        if (currentUser.UserName == Eval("UserName").ToString())
    {
        Control deleteButton = e.Item.FindControl("Button2");
        deleteButton.Visible = true;
    }
</code></pre>

<p>}</p>

<p>But this is giving me error. It States that 'System.EventArgs' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.EventArgs' could be found. I placed this code in my PostComment button. Have i done wrong anywhere?</p>

<p>This is the error that is showing.</p>

<p>Compilation Error</p>

<p>Description: An error occurred during the compilation of a resource required to service   this request. Please review the following specific error details and modify your source    code appropriately. </p>

<p>Compiler Error Message: CS1061: 'System.EventArgs' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.EventArgs' could be found (are you missing a using directive or an assembly reference?)</p>

<p>Source Error:</p>

<pre><code>Line 59:         TextBox2.Text = string.Empty;
Line 60: 
Line 61:         if (e.Item.ItemType == ListViewItemType.DataItem)
Line 62:         {
Line 63:             ListViewDataItem currentItem = (ListViewDataItem)e.Item;
</code></pre>
