This is a migrated thread and some comments may be shown as answers.

Dynamic control Using RadAjaxManager

3 Answers 141 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
KlimUser
Top achievements
Rank 2
KlimUser asked on 20 Nov 2008, 05:54 PM
Hello EveryOne!!
Well, My problem is the next:
I'm already creating controls dynamically using RadAjaxManager
Until There Everything works like a charm!! =D
Here the code 
foreach (DataRow dr in dt.Rows)  
            {  
                RadioButtonList rbl = new RadioButtonList();  
                try  
                {  
                    rbl.ID = "rbl_" + dr["PK"].ToString();  
                    rbl.Items.Add(new ListItem("SI""1"));  
                    rbl.Items.Add(new ListItem("NO""0"));  
                    if (Convert.ToBoolean(dr["isCompleted"].ToString()))  
                    { rbl.SelectedValue = "1"; }  
                    else { rbl.SelectedValue = "0"; }  
                    rbl.RepeatDirection = RepeatDirection.Horizontal;  
                    this.panel.Controls.Add(rbl);  
                }  
                catch (Exception LoEx) { this.lblMsgError.Text = LoEx.Message; }  
                finally  
                {  
                    rbl = null;  
                    i++;  
                }  
            } 
That is the code for create the controls
and as I said, it works like a charm!
But my problem is when I want to save the data bounded to the control (dynamic controls are a common RadioButtons and they have a 1 for a "Yes" or 0 for "No" )
and when I click on the Update button

3 Answers, 1 is accepted

Sort by
0
KlimUser
Top achievements
Rank 2
answered on 13 Dec 2008, 11:33 PM
I use this code
ContentPlaceHolder cphM = (ContentPlaceHolder)Master.FindControl("cphMain");  
                        Panel oPanel = new Panel();  
                        foreach (Control c in cphM.Controls)  
                        {  
                            if (c.GetType() == oPanel.GetType())  
                            {  
                                foreach (Control oCp in c.Controls)  
                                {  
                                    RadioButtonList rbl = (RadioButtonList)c;  
                                    strRblValue = rbl.SelectedValue;  
                                }  
                                  
                            }  
                        }  
0
KlimUser
Top achievements
Rank 2
answered on 15 Dec 2008, 02:38 PM
But In the collection of the cphM doesn't exist the RadioButton and, later I though that the must be into the Panel but, nooo!!!
I know it has to be something related to the use of Ajax to avoid the postback when are created the controls.
but I can't figure out which could be the way to get these controls and its values =(.
I hope somebody in the forum knows a solution snif snif =(.
Thanks in advanced
KlimUser


0
Maria Ilieva
Telerik team
answered on 16 Dec 2008, 07:48 AM
Hi Klim,

Could you please let us know whether the problem persists if you disable the Ajax on the page and use regular postbacks ?

Sincerely yours,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
KlimUser
Top achievements
Rank 2
Answers by
KlimUser
Top achievements
Rank 2
Maria Ilieva
Telerik team
Share this question
or