0
我有一個頁面,我正在檢查幾組單選按鈕的值。對於每個組,如果選擇了單選按鈕,這是我需要保存以供稍後存儲在我的數據庫中的屬性。由於代碼現在正確,單選按鈕Checked屬性被正確設置爲「true」,但是,當我從頁面讀回時,它將返回爲「假」,即使我可以看到它實際上已被選中屏幕。VB.NET單選按鈕選中的屬性沒有顯示爲正確
這裏是代碼塊:
標記:
<form action="#">
<div class="card-content center-align">
<div class="row">
<div class="col s4 m4 l4">
<asp:RadioButton CssClass="with-gap" ID="rdoArabic1" runat="server" GroupName="ethnicity" />
<label>Arabic, Middle Easterner</label>
</div>
<div class="col s4 m4 l4">
<asp:RadioButton CssClass="with-gap" ID="rdoAsian1" runat="server" GroupName="ethnicity" />
<label>Asian, Pacific Islander, Indian</label>
</div>
<div class="col s4 m4 l4">
<asp:RadioButton CssClass="with-gap" ID="rdoBlack1" runat="server" GroupName="ethnicity" />
<label>African American or Black</label>
</div>
</div>
</div>
<div class="card-content center-align">
<div class="row">
<div class="col s4 m4 l4">
<asp:RadioButton CssClass="with-gap" ID="rdoWhite1" runat="server" GroupName="ethnicity" />
<label>White, Anglo, European American</label>
</div>
<div class="col s4 m4 l4">
<asp:RadioButton CssClass="with-gap" ID="rdoHispanic1" runat="server" GroupName="ethnicity" />
<label>Hispanic, Latino</label>
</div>
<div class="col s4 m4 l4">
<asp:RadioButton CssClass="with-gap" ID="rdoOther1" runat="server" GroupName="ethnicity" />
<label>Other</label>
</div>
</div>
</div>
</form>
VB代碼:
If rdoArabic1.Checked = True Then
ethnicity = "1"
ElseIf rdoAsian1.Checked = True Then
ethnicity = "2"
ElseIf rdoBlack1.Checked = True Then
ethnicity = "3"
ElseIf rdoWhite1.Checked = True Then
ethnicity = "4"
ElseIf rdoHispanic1.Checked = True Then
ethnicity = "5"
ElseIf rdoOther1.Checked = True Then
ethnicity = "6"
End If
不管怎樣,我一直在敲我的頭靠在這堵牆,而現在和我似乎無法看到我錯過了什麼導致它重置。我已經遍歷了代碼,並且在頁面加載並處理來自數據庫的信息時,Checked屬性被設置爲True,但由於某種原因,它並沒有正確地從表單中讀取它。