Click here to Skip to main content
15,902,032 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Issue with Validator control Pin
Vipul Mehta7-Apr-08 22:03
Vipul Mehta7-Apr-08 22:03 
QuestionHow to get Virtual Path of Web Service [modified] Pin
samrat.net7-Apr-08 18:19
samrat.net7-Apr-08 18:19 
AnswerRe: How to get Virtual Path of Web Service Pin
Christopher Duncan8-Apr-08 17:55
Christopher Duncan8-Apr-08 17:55 
GeneralCannot get IIS pickup directory Pin
Piyush Vardhan Singh7-Apr-08 18:18
Piyush Vardhan Singh7-Apr-08 18:18 
GeneralRe: Cannot get IIS pickup directory Pin
N a v a n e e t h7-Apr-08 18:38
N a v a n e e t h7-Apr-08 18:38 
GeneralRe: Cannot get IIS pickup directory Pin
Piyush Vardhan Singh7-Apr-08 19:10
Piyush Vardhan Singh7-Apr-08 19:10 
GeneralRe: Cannot get IIS pickup directory Pin
N a v a n e e t h7-Apr-08 19:21
N a v a n e e t h7-Apr-08 19:21 
QuestionDynamically added controls don't appear in View's control collection. (VB) Pin
WebMaster7-Apr-08 15:08
WebMaster7-Apr-08 15:08 
I've been working with ASP .NET and data for a couple months now. I'm creating a web app that is more or less a "virtual worksheet" with multiple choice questions. I get the question text and four answers from an Access database. Using data from an invisible GridView, I create Labels and RadioButtonLists at runtime and add them inside a View in my MultiView.

For I As Integer = 0 To Me.gvQMultipleChoice.Rows.Count - 1<br />
            Dim lbl As New Label<br />
            lbl.ID = "lblQ" & I<br />
            lbl.Text = I + 1 & ". " & Me.gvQMultipleChoice.Rows(I).Cells(0).Text<br />
            Me.vw1.Controls.AddAt(Me.vw1.Controls.Count - 5, lbl)<br />
            Dim rad As New RadioButtonList<br />
            rad.ID = "rad" & I<br />
            For I2 As Integer = 0 To 3<br />
                rad.Items.Add(SwitchChar(I2) & ". " & Me.gvQMultipleChoice.Rows(I).Cells(I2 + 1).Text)<br />
            Next<br />
            rad.RepeatDirection = RepeatDirection.Horizontal<br />
            Me.vw1.Controls.AddAt(Me.vw1.Controls.Count - 5, rad)<br />
Next


Basically, make a Label, get its question text, add it to the View. Same with the RadioButtonList. This works fine. My problem is later, when I am trying to find out which RadioButton is selected. Me.vw1.Controls doesn't contain any of these Labels or RadioButtonLists.

<br />
Dim myControls As ControlCollection = Me.vw1.Controls<br />
For I As Integer = 0 To myControls.Count - 1<br />
            If myControls(I).ID <> Nothing Then<br />
                If myControls(I).ID.StartsWith("rad") Then<br />
                    Dim rad As RadioButtonList = Me.vw1.Controls(I)<br />
                    ans &= rad.SelectedIndex<br />
                Else<br />
                    'ignore<br />
                End If<br />
            End If<br />
Next


This should work fine, I'm confident it would. But again, the problem is that the dynamically created controls aren't in the list. Does anyone know why it would be like this.

By the way, the Labels and RadioButtonLists show up, and I can select a RadioButton. The second bit of code is executed on a Button.Click event.

Thanks!

(Yes, this also in the Web Dev section. Sorry I posted there first.)

Evan Stoner
Breeze Innovations

GeneralRe: Dynamically added controls don't appear in View's control collection. (VB) Pin
Christian Graus7-Apr-08 18:03
protectorChristian Graus7-Apr-08 18:03 
GeneralRe: Dynamically added controls don't appear in View's control collection. (VB) Pin
WebMaster8-Apr-08 4:30
WebMaster8-Apr-08 4:30 
GeneralRe: Dynamically added controls don't appear in View's control collection. (VB) Pin
Christian Graus8-Apr-08 11:12
protectorChristian Graus8-Apr-08 11:12 
GeneralRe: Dynamically added controls don't appear in View's control collection. (VB) Pin
WebMaster8-Apr-08 11:26
WebMaster8-Apr-08 11:26 
QuestionHow to Resize a pop-up according to it's content height and width Pin
Tarik Guney7-Apr-08 13:38
Tarik Guney7-Apr-08 13:38 
GeneralMenuItem selected value Pin
kmuthuk7-Apr-08 10:31
kmuthuk7-Apr-08 10:31 
GeneralRe: MenuItem selected value Pin
Chatura Dilan7-Apr-08 15:36
Chatura Dilan7-Apr-08 15:36 
QuestionDate Pin
jonhbt7-Apr-08 9:22
jonhbt7-Apr-08 9:22 
GeneralRe: Date Pin
pmarfleet7-Apr-08 10:28
pmarfleet7-Apr-08 10:28 
GeneralRe: Date Pin
biswa477-Apr-08 20:21
biswa477-Apr-08 20:21 
GeneralRe: Date Pin
Herman<T>.Instance8-Apr-08 4:40
Herman<T>.Instance8-Apr-08 4:40 
GeneralRe: Date Pin
pmarfleet8-Apr-08 11:07
pmarfleet8-Apr-08 11:07 
GeneralRe: Date Pin
Herman<T>.Instance8-Apr-08 23:40
Herman<T>.Instance8-Apr-08 23:40 
GeneralRe: Date Pin
pmarfleet9-Apr-08 9:23
pmarfleet9-Apr-08 9:23 
GeneralRe: Date Pin
pmarfleet8-Apr-08 11:05
pmarfleet8-Apr-08 11:05 
GeneralUploading Image to Server Pin
Paul McGann7-Apr-08 9:21
professionalPaul McGann7-Apr-08 9:21 
GeneralRe: Uploading Image to Server Pin
Christian Graus7-Apr-08 11:35
protectorChristian Graus7-Apr-08 11:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.