Solved

[VS 2008] Datarepeater checkbox repeats every 10 rows

Posted on 2014-10-10
3
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 42

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 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