具有SelectedIndexChanged的无线电列表未在radgrid内部触发

时间:2012-10-29 15:40:02

标签: asp.net user-controls postback telerik-grid onselect

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

我已经在此Q. 1Q. 2上提出了2个问题,这些问题表明需要在aspx页面中设置OnSelectedIndexChanged。我的问题是该控件在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);

                    }
            }

        }

0 个答案:

没有答案