How do I update or delete data on Repeater control using checkboxes? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How do I update or delete data on Repeater control using checkboxes?

Hi to every one...

I am developing a small ASP.NET application. It has a page where visitor can post comments, a page for the administrator to view posted comment. I display the comments on a (data) Repeater control with two checkboxes for each record to either mark posts as read or to delete the post; with both enabled property set to true.

For a test, I added a label to tell me the selected (checkbox) item. But each time I check any of the checkboxes, I don't get the expected result. This is my code-behinde file under the Page_Load event handler:

For i As Integer = 0 To rptPosts.Items.Count - 1
Dim row As RepeaterItem = rptPosts.Items(i)
Dim isRead As Boolean = CType(row.FindControl("chkRead"), CheckBox).Checked
Dim isDeleted As Boolean = CType(row.FindControl("chkDelete"), CheckBox).Checked
Dim MessageLabel As Label = CType(row.FindControl("lblMessage"), Label)
If isRead Then
MessageLabel.Text = "Read checked"
ElseIf isDeleted Then
MessageLabel.Text = "Delete checked"
End If Next

Please help me out.
Sign In or Register to comment.