I write this codes :

  TabContainer TabContainer1 = new TabContainer();
        TabContainer1.ID = "TabContainer1";

        HtmlTableRow row = new HtmlTableRow();
        HtmlTableCell cell = new HtmlTableCell();



        for (int toplam_grp = 0; toplam_grp < 1; toplam_grp++)
        {



        Panel my_panel= new Panel();
        my_panel.ID = toplam_grp + "my_panel";
        for (int j = 0; j < 10; j++)
        {
            Label my_label = new Label();

            my_label.ID = j + 10 * toplam_grp + "mylabel";//burda 10 j nin sınırı olcak

            my_label.Text = "asdasdas";

            RadioButtonList radioButtonList = new RadioButtonList();
            radioButtonList.ID = j + 10 * toplam_grp + "radioButton";
            radioButtonList.RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal;
         for (int i = 0; i < 5; i++)
            { 
                radioButtonList.Items.Add(((char)(i + 65)).ToString());                
            }
            my_panel.Controls.Add(my_label);           /////////////////////////burda yanyana gözükse daha iyi olur
            my_panel.Controls.Add(radioButtonList);

        }



        TabPanel tab = new TabPanel();
        tab.ID = toplam_grp+"tab1";
        tab.HeaderText =toplam_grp+"nbr";

        TabContainer1.Tabs.Add(tab);
        TabContainer1.Tabs[toplam_grp].Controls.Add(my_panel);

        }

        cell.Controls.Add(TabContainer1);
        row.Cells.Add(cell);

        myplace.Rows.Add(row);

I create a tabcontainer and one tab and in tab I create 10 radiobuttonlist(I give them ids each one) which have 5 members. And I write this code to reach radiobuttonlist but ı dont reach because dont find their ids :

string ss = "";
        for (int i = 0; i < 10; i++)
        {

            ss += ((RadioButtonList)(FindControl(i + "radioButton"))).SelectedIndex + "\n";

        }
        MessageBox.Show(ss);

for example first radiobuttonlist id : 0radioButton but it cant found.What can I do.Thanks for answering...

有帮助吗?

解决方案

The whole code is a little confusing for me but I try to add my 2 cents.

You need to execute FindControl against the RadiobuttonList container and not against the page.

So, for instance, if you added a control named RadioButtonList1 to a asp.net panel named Panel1 you would have to do

 Panel1.FindControl("RadioButtonList1 ")
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top