我使用AJAX根据条件使用户控件包含一个包含标签和RadioButtonList或CheckBoxList的面板。 。 有在.aspx页面中的占位符,其中控制应在 我需要从占位 我试图找到这个名单:在占位符中查找控件
public static int id = 1;
QuestionPanelControl q1 ;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadQuestionPanelControl();
}
}
//Next Button
protected void Button1_Click(object sender, EventArgs e)
{
id++;
if (id <= 10)
{
//LoadQuestionPanelControl();
PlaceHolder p = (PlaceHolder)Page.FindControl("PlaceHolder1");
QuestionPanelControl c1 = (QuestionPanelControl)p.FindControl("QuestionPanelControl1");
// QuestionPanelControl c1 = (QuestionPanelControl)p.FindControl("Panel_Question");
RadioButtonList rb = c1.ChildRadioButtonList;
if (rb.SelectedIndex == 0)
{
//DB
}
else if (rb.SelectedIndex == 1)
{
//DB
}
else
{
Lsb_Unanswered.Items.Add("Question #" + id);
}
LoadQuestionPanelControl();
}
}
public void LoadQuestionPanelControl()
{
Session.Add("ID",id);
q1= new QuestionPanelControl();
q1.ID = "QuestionPanelControl1";
Control c = Page.LoadControl("QuestionPanelControl.ascx");
PlaceHolder1.Controls.Clear();
PlaceHolder1.Controls.Add(c);
}
当我用破发点,我发现,控制P的属性0.
注意:ChildRadioButtonList是QuestionPanelControl中的一个属性。 任何建议...
如何以及何时将QuestionPanelControl添加到占位符? – 2011-04-04 19:02:22
我已编辑代码:) – noor 2011-04-04 19:08:38