I have a radio button list. When the page is loaded I have some scripts and other things that run to determine if an ID has passed or failed a test. So what I am trying to actually do is when that page loads set my radio button to fail after the script runs
Here is the list:
<asp:radiobuttonlist id="rblInspectionStatus" CssClass="descbold" runat="server" repeatColumns="2" repeatDirection="Horizontal">
<asp:listitem Value="Pass">Pass</asp:listitem>
<asp:listitem Value="Fail">Fail</asp:listitem>
</asp:radiobuttonlist>
What I have tried is:
rblInspectionStatus.Items.FindByValue("Fail").Selected = True
rblInspectionStatus.Items.FindByText("Fail").Selected = True
rblInspectionStatus.SelectedIndex |SelectedItem | SelectedValue
I don't know what you are trying to do in that Sub
or as User Tony Hinkle and User NoAlias are trying to say is correct but this is my assumption:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
cn.Open() 'Opens the connection
cmd = New SqlCommand("SELECT PF FROM TABLE WHERE ID = '" & Session("ID") & "'", cn)
drr = cmd.ExecuteReader
If drr.Read Then
rblInspectionStatus.ClearSelection()
rblInspectionStatus.Items.FindByValue(drr.Items("PF")).Selected = True
'FIELD PF data either Pass or Fail
ElseIf Not drr.Read Then
rblInspectionStatus.ClearSelection()
rblInspectionStatus.SelectedIndex = -1
End If
cn.Close() 'Close the connection
End Sub