Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Is there a way of selecting all the remaining questions automatically from a radiolist? (with the Incorrect answer)

Suppose I want to remove page validation on an exam to let the page automatically update the datasource based on a timer. The problem here is that some users may not have answered all questions before the page updates. This will result in some of the Radiobutton.selecteditem.text/values being returned as blank. This is the problem. I am getting the error cannot be set to null object.

Is there a way of selecting all the remaining questions automatically from a radiolist? (with the Incorrect answer)

The datavaluefield is what contains the correct or Incorrect values.

Any suggestions?

Im using VB.NET
0
pgilfeather
Asked:
pgilfeather
  • 2
1 Solution
 
bramsquadCommented:
i posted this after you accepted the answer to the question i helped you with, have you tried this...

For nCount = 0 To RadioButtonList.Items.Count - 1
      If RadioButtonList.Items(nCount).Selected = False Then
             RadioButtonList.Items(nCount).Value = "NoSelectedValue"
      End if
Next

~b
0
 
Hans LangerCommented:
Do you have more than 1 RadioButtonList in a page , or just 1 for each page ?


For the code of you can add

if  not RadioButtonList.SelectedItem Is Nothing then
For nCount = 0 as integer To RadioButtonList.Items.Count - 1
      If RadioButtonList.Items(nCount).Selected = False Then
             RadioButtonList.Items(nCount).Value = "NoSelectedValue"
      End if
Next
0
 
Hans LangerCommented:
Sorry , Problem with the connection,

Do you have more than 1 RadioButtonList in a page , or just 1 for each page ?

Try This

      If Not RadioButtonList .SelectedItem Is Nothing Then  ' that mean RadioButtonList have not SelectedItem
         For MyIndex As Integer = 0 To RadioButtonList .Items.Count - 1
            If RadioButtonList .Items(MyIndex ).Value = "NoSelectedValue" Then
               RadioButtonList .Items(MyIndex ).Selected = True
               Exit For
            End If
         Next
      End If

GL
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now