我有:無法趕上單選按鈕列表裏面的SelectedValue電網
<asp:TemplateField HeaderText="Choose Option">
<ItemTemplate>
<asp:RadioButtonList ID="rdbChoice" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="A">A</asp:ListItem>
<asp:ListItem Value="B">B</asp:ListItem>
<asp:ListItem Value="C">C</asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>
在按一下按鈕,我想要得到的RadioButtonList.SelectedValue
。我嘗試:
protected void btnsubmit_Click(object sender, EventArgs e)
{
for (int i = 0; i <= gvQuestion.Rows.Count - 1; i++)
{
RadioButtonList rd1 = (RadioButtonList)gvQuestion.FindControl("rdbChoice");
string rd = rd1.SelectedValue.ToString();
}
}
,但我得到一個錯誤Object reference not set to an instance of an object.
什麼是我的錯?
謝謝lot.Its做工perfectly.Waiting一時接受答:) –