C#代码求教

来源:百度知道 编辑:UC知道 时间:2024/06/07 09:05:27
Aline 和 Tline 是一组radiobutton

string[] aa = { "11", "22", "33", "33" };
string[] bb = { "2222", "33333" };

if (Aline.Checked)
{
dropdownlist.DataSource = aa;
dropdownlist.DataBind();
}
else
{
dropdownlist.DataSource = bb;
dropdownlist.DataBind();
}

为什么运行只显示bb的一组啊

1.你应该是把这段代码放在Page_Load里面了!!当你运行的时候页面出来是两个都没有选,所以就执行else语句
Aline.AutoPastBack=True;
Tline.AutoPastBack=true;
if (Aline.Checked)
{
dropdownlist.DataSource = aa;
dropdownlist.DataBind();
}
else
{
dropdownlist.DataSource = bb;
dropdownlist.DataBind();
}

Aline.Checked=false了呗

if else 满组条件只会运行一个
改成if if
满足条件就能运行2个了

radiobutton Postback = true 了吗?