Events from dynamic checkboxes sometimes handled the wrong way

G

galien8

Dear Newsgroup Readers,

I have a problem with dynamic controls, in a DotNetNuke module, and
event handlers in VB.NET ASP.NET 2.0. Events are firing and being
handled, sometimes good but also sometimes in a wrong way. I always
unchecked the first of the list (See Also Source Code Below):

CheckBox1 sender ID = D0
CheckBox2
CheckBox3
CheckBox4
CheckBox5

CheckBox2 sender ID = D1
CheckBox3
CheckBox4
CheckBox5

CheckBox2 sender ID = D0
CheckBox4
CheckBox5

CheckBox4 sender ID = 1
CheckBox5

CheckBox5 CheckChanged event does not fire first time must uncheck
again

(NB: ID of the sender should always be D0)

And so on. The last remaining one does not fire an event and must be
unchecked again to be removed

I tried everything, code examples on the internet are more or less the
same with mine.
(I tried EnableViewState false and true for page, panel and dynamic
checkboxes)

Any ideas what the problem is? I do not believe that it is one of
those hard to debug asynchrone bugs, because the code is so simple!

PLEASE HELP!

Kind regards,

Johan van der Galien.

Code snipped:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim MyCustomIngredients As New List(Of CustomIngredients)
Dim MyDBItemCheckBox As CheckBox

MyCustomIngredients =
MyDataBase.SelectAllCustomIngredients(UserId)

Me.DBMaintenancePanel.Controls.Clear()

Dim I As Integer
For I = 0 To MyCustomIngredients.Count - 1
MyDBItemCheckBox = New CheckBox
MyDBItemCheckBox.AutoPostBack = True
MyDBItemCheckBox.Checked = True
'MyDBItemCheckBox.EnableViewState = False
MyDBItemCheckBox.ID = "D" & I.ToString
MyDBItemCheckBox.Text =
MyCustomIngredients(I).Description
AddHandler MyDBItemCheckBox.CheckedChanged, AddressOf
ADBItemCheckChanged
Me.DBMaintenancePanel.Controls.Add(MyDBItemCheckBox)
Me.DBMaintenancePanel.Controls.Add(New
LiteralControl("<br />"))
Next
End Sub

Public Sub ADBItemCheckChanged(ByVal sender As Object, ByVal e
As EventArgs)
Me.IngredientsPanel.Visible = False
Me.DBMaintenancePanel.Visible = True
Me.OUTPUTLabel.Visible = False
Me.ItemsDropDownList.SelectedIndex = 0
Me.DBMaintenanceButton.Visible = False
Me.FinishDBMaintenanceButton.Visible = True
Me.ADDButton.Enabled = False

Dim MyDBItemCheckBox As CheckBox = DirectCast(sender,
CheckBox)

Dim MyDataBase As New SqlDataProvider
Dim MyCustomIngredients As New List(Of CustomIngredients)

'1) Load list of items from database
MyCustomIngredients =
MyDataBase.SelectAllCustomIngredients(UserId)

'2) Remove unchecked item from database

MyDataBase.DeleteCustomIngredient(MyCustomIngredients(CInt(MyDBItemCheckBox.ID.Trim("D"))))
End Sub

PS: I am using Visual Web Developer 2005 Express.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top