views:

383

answers:

2

i have create the wizard control , in side this i have create the repeater control.this repeater control has three radio buttons.all are created with dynamically.I want to fire a radio button checkedchange event.

find the code:

       **Panel objPanel = (Panel)Wizard1.WizardSteps[Wizard1.ActiveStepIndex].Controls[5];
        Repeater reptrAddQuestion = new Repeater();
        reptrAddQuestion.ID = "reptrAddQuestion" + (count-1);
        string[] obj = new string[2];
        reptrAddQuestion.Visible = true;
        reptrAddQuestion.DataSource = obj;
        reptrAddQuestion.DataBind();
        reptrAddQuestion.EnableViewState = true;
        int controlIdValue = (count - 1) + 1;
        for (int index = 0; index <= reptrAddQuestion.Items.Count - 1; index++)
        {
            RadioButton RdoBtn = new RadioButton();
            RdoBtn.AutoPostBack = true;
            RdoBtn.ID = "RdoBtn" + controlIdValue.ToString();
            RdoBtn.CheckedChanged += new System.EventHandler(RdoBtn_CheckedChanged);
            RdoBtn.EnableViewState = true;
            reptrAddQuestion.Controls.Add(RdoBtn);
            controlIdValue += 1;
        }
        objPanel.Visible = true;
        objPanel.Controls.Add(reptrAddQuestion);**

    public void RdoBtn_CheckedChanged(object sender, EventArgs e)
    {

    }

advance thanks for this help. Regards, Devathidhan.S

A: 

It depends in which part of the Web Page life cycle you are creating the controls.

If you want the controls to handle postbacks and events, you must create them in the pages "OnInit" or "OnPreInit" function.

If you are creating these controls on Page_Load or later, it's too late. The controls will not fire events or hold user changes, because by then the postback information has already been processed.

Andrew Shepherd
yes Andrew i have crate that on dropdownlist SelectedIndexChanged event ,can i create on repeater init event. will it fire?
thanks Andrew............
A: 

Try setting the checkbox's AutoPostBack property to true. If that doesn't fix the problem, then it's likely a lifecycle issue, as Andrew said.

Chris
Based on the dropdownlist SelectedIndexChanged event , i have to create the repeater control. Is there any chance to solve this issue?.