SelectedIndexChanged的Radio列表在radgrid内部没有触发

我有一个用户控件,它包含一个在SelectIndexChanged上更新下拉菜单的广播列表。 我把基本页面放在一起,并将用户控件添加到工作正常的页面,但是当我将控件移动到radgrid内时它不起作用,它会回发但不会调用SelectIndexChanged事件。

我在这个Q. 1和Q.2中提出了2个以前的问题,它们说OnSelectedIndexChanged需要在aspx页面中设置。 我的问题是该控件不存在于aspx页面中,并在稍后创建,因此该解决方案对我无效。

工作代码

working.aspx

<TT:ToolTipControl ID="ToolTipEdit" runat="server" />

working.aspx.cs

protected void Page_Load(object sender, EventArgs e)
{
    ToolTipEdit.getEditToolTip("POL_TERM_CD", "DataPolTermDropDownlistEdit");
}

用户控制

userControl.ascx.cs

public void getEditToolTip(string fieldName, string ddlName)
{
     DataPolTermRadioListBox ccPolTermRadioListBox = new DataPolTermRadioListBox(); //custom radio list
     ccPolTermRadioListBox.ID = "PolTermRadioListBox";
     ccPolTermRadioListBox.AutoPostBack = true;
     ccPolTermRadioListBox.SelectedIndexChanged += new System.EventHandler(updateParent);
     ToolTip.Controls.Add(ccPolTermRadioListBox);
}

破碎的代码

brokenPage.aspx

<telerik:RadGrid ID="rgState" Skin="WebBlue" runat="server" OnNeedDataSource="rgState_NeedDataSource"
     AutoGenerateColumns="False" OnPreRender="rgState_PreRender">
     <MasterTableView DataKeyNames="wrtnStPolId" AllowAutomaticUpdates="false" AllowAutomaticDeletes="true"
         AllowAutomaticInserts="false" CommandItemDisplay="Top" AllowMultiColumnSorting="True"
         EditMode="InPlace" GroupLoadMode="Server" Caption="State(s) and Exposure(s)">
         <Columns>
             <telerik:GridTemplateColumn AllowFiltering="false" HeaderText="Pol Type Nstd" SortExpression="nonStdPolTypeCd"
                 UniqueName="nonStdPolTypeCd">
                 <ItemTemplate>
                     <asp:Label ID="lblNonStdPolTypeCd" runat="server" align="center" Text='<%#DataBinder.Eval(Container.DataItem, "nonStdPolTypeCd")%>' />

                 </ItemTemplate>
                 <EditItemTemplate>
                     <cc1:DataNonStdTypeCdDropDownList ID="ddlNonStdTypeCd" runat="server" ClientIDMode="Predictable">
                     </cc1:DataNonStdTypeCdDropDownList>
                     <TT:ToolTipControl ID="ttcNonStdPolTypeCdEdit" runat="server" />
                 </EditItemTemplate>
             </telerik:GridTemplateColumn>
         </Columns>
     </MasterTableView>
 </telerik:RadGrid>

brokenPage.aspx.cs

protected void rgState_PreRender(object sender, EventArgs e)
        {

            RadGrid rgExpMod = (RadGrid)sender;

            foreach (GridDataItem row in rgExpMod.Items)
            {

                    GridDataItem gdiItem = (GridDataItem)row;

                    if (row.FindControl("ttcNonStdPolTypeCdEdit") != null)
                    {

                        DropDownList ddl = (DropDownList)row.FindControl("ddlNonStdTypeCd");
                        ddl.ID += row.RowIndex;
                        ddl.SelectedIndex = 2;

                        NCCI.PDC.Web.Controls.ucToolTip ttcNonStdPolTypeCdEdit = (NCCI.PDC.Web.Controls.ucToolTip)row.FindControl("ttcNonStdPolTypeCdEdit");
                        ttcNonStdPolTypeCdEdit.getEditToolTip("non_std_pol_type_cd", ddl.ID);

                    }
            }

        }
链接地址: http://www.djcxy.com/p/67231.html

上一篇: Radio list with SelectedIndexChanged not firing inside radgrid

下一篇: DropDownList doesn't call SelectedIndexChanged?