SteveoAtilla Posted September 14, 2005 Posted September 14, 2005 Okay. Strange situation. I have a mobile application that I am developing. Part of it displays a dynamic list of questions with checkmarks, based on a SQL Query. No big deal. All question controls are created in Page_Init, like so: selDynamic = New System.Web.ui.MobileControls.SelectionList selDynamic.ID = "Check" & Trim(Str(LoopVar)) & "-" & QuestionArray(10, LoopVar) selDynamic.SelectType = MobileControls.ListSelectType.CheckBox selDynamic.Font.Name = "Arial" selDynamic.Font.Size = MobileControls.FontSize.Small If Len(Trim(QuestionArray(7, LoopVar))) > 0 Then If QuestionArray(10, LoopVar) = 0 Then ' Checked EmpInits = " - " & QuestionArray(13, LoopVar) selDynamic.ForeColor = Color.Red Else EmpInits = "" selDynamic.ForeColor = Color.Black End If selDynamic.Items.Add(QuestionArray(7, LoopVar) & ". " & QuestionArray(4, LoopVar) & EmpInits) Else selDynamic.Items.Add(QuestionArray(4, LoopVar)) End If If QuestionArray(10, LoopVar) = "0" Then selDynamic.SelectedIndex = 0 frmDynamic.Controls.Add(selDynamic) It creates the controls perfectly. I have a dropdown list so the user can select their initials from a list I have a button on the page to save responses back to the database. Good. Now, here is the bizarre part. When you check off a question and save the first time, it works fine. If you then, without leaving the page, select the same question (un-check the box), it doesn't properly read the selectedindex of the control. I cannot explain it. Here is the code for the button: Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click lblDynamicDebug.Text = "Before Click: " & CType(frmDynamic.Controls.Item(19), MobileControls.SelectionList).SelectedIndex.ToString SaveChecklist() End Sub Index 19 is the first question on the page. Since there is only a selection list in Mobile, it is a selection list of type CheckBox, and there is only one element in the list. Therefore, if the checkbox is checked, the resulting .SelectedIndex is 0. If the checkbox is NOT checked, the resulting .SelectedIndex is -1. If a question is checked, then the button is clicked, I get BeforeClick: 0 [/Quote] Now, un-checkikng the box and clicking the button again gives this: BeforeClick: 0 [/Quote] Same result. Now for more bizarre happiness. The checkbox goes BACK to CHECKED! Un-check it again and click, and you get this: BeforeClick: -1 [/Quote] I have no idea why it won't properly read the state of the checkbox after it is saved. I have no ideas. HELP!!!!!! Kahuna Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
SteveoAtilla Posted September 20, 2005 Author Posted September 20, 2005 No help on this? Quote The three most important things in life: God, your family, and the Green Bay Packers -- Not necessarily in that order. Winning is not a sometime thing. You don't win once in a while, you don't do things right once in a while, you do them right all the time. Winning is a habit. Unfortunately, so is losing. -- Vincent T. Lombardi
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.