Solved

[VS 2008] Datarepeater checkbox repeats every 10 rows

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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.  …
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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