Solved

[VS 2008] Datarepeater checkbox repeats every 10 rows

Posted on 2014-10-10
3
162 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

626 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