Finden Kontrollen in Platzhalter

ich bin mit AJAX, um ein Benutzer-Steuerelement enthält ein panel, das label enthält und RadioButtonList oder CheckBoxList nach einer Bedingung.
Es ist ein Platzhalter .aspx-Seite, wo diese Kontrolle sollte in.
Ich muss Liste von Platzhalter
Ich versuchte dies:

 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);

    }

Wenn ich Pause Punkte, fand ich, dass die Controls-Eigenschaft von p ist 0.

Hinweis: ChildRadioButtonList ist eine Eigenschaft, die in der QuestionPanelControl.
Irgendwelche Vorschläge...

Wie und Wann sind Sie mit dem hinzufügen QuestionPanelControl der Platzhalter?
ich habe bearbeitet-code 🙂

InformationsquelleAutor noor | 2011-04-04

Schreibe einen Kommentar