我在带有RadioButtonList的.aspx页面上有一个表单。我使用ArrayList和BindData()填充列表。当我尝试获取列表的选定值时,我得到一个空对象。
protected void Page_Load(object sender, EventArgs e)
{
q_LBL.Text = "What is the right answer?";
ArrayList options = new ArrayList();
options.Add("a");
options.Add("b");
options.Add("c");
options.Add("d");
options.TrimToSize();
options_RBL.DataSource = options;
options_RBL.DataBind();
}
protected void submit_BTN_Click(object sender, EventArgs e)
{
fb_LBL.Text = options_RBL.SelectedValue;
}
答案 0 :(得分:1)
试试这个
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
q_LBL.Text = "What is the right answer?";
ArrayList options = new ArrayList();
options.Add("a");
options.Add("b");
options.Add("c");
options.Add("d");
options.TrimToSize();
options_RBL.DataSource = options;
options_RBL.DataBind();
}
}
protected void submit_BTN_Click(object sender, EventArgs e)
{
fb_LBL.Text = options_RBL.SelectedValue;
}