Solved

[VS 2008] Datarepeater checkbox repeats every 10 rows

Posted on 2014-10-10
3
141 Views
Last Modified: 2014-11-09
I'm writing an application in VB.net using the Visual Basic Power Packs DataRepeater. I have a loop that runs on the rows with a checkbox checked in them. When I run the loop it checks every 10th row from the ones I've selected. There is no other event linked to the DataRepeater or the controls inside. Just a button at the bottom. The checkbox is not bound to anything. Any reason why the DataRepeater would do this?  The checkbox is not bound to a database field.

I read this checkboxstate with the following code:

  For i As Integer = 0 To dr.ItemCount - 1
                Me.dr.CurrentItemIndex = i                
                Dim item As DataRepeaterItem = Me.dr.CurrentItem

                Dim chk As New CheckBox
                chk = item.Controls("chk1")               

                If chk.CheckState = CheckState.Checked Then
                    MsgBox("CHECKED!!|)                   
                End If

            Next

Open in new window

0
Comment
Question by:Program1981
  • 2
3 Comments
 
LVL 41

Expert Comment

by:pcelba
ID: 40374659
I would recommend to display states for all DR rows incl. the i and chk.CheckState value in Debug window.

BTW, the Dim  chk As New CheckBox  is not necessary and you could use just

Dim  chk As CheckBox = item.Controls("chk1")
0
 

Accepted Solution

by:
Program1981 earned 0 total points
ID: 40421500
Solution (doesn't need to set the currentindex):


 For Each rowItem As DataRepeaterItem In dr.Controls
                
                Dim chk As New CheckBox

                chk = rowItem.Controls("chkApply")

                If chk.CheckState = CheckState.Checked Then

                    If rowItem.ItemIndex <> -1 Then
                        j += 1
                    End If

                End If
         next

Open in new window

0
 

Author Closing Comment

by:Program1981
ID: 40431053
Get a solution with try (and error :-))
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now