Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

[VS 2008] Datarepeater checkbox repeats every 10 rows

Posted on 2014-10-10
3
Medium Priority
?
179 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 43

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

972 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