0

I´m having trouble grabbing RadComboBox when editing inline from a RadGrid. When I try to find the correct control through this GridEditableItem I always receive null. Can anyone throw me some pointers in how to access the RadCombobox from my code below?

My ascx.cs file:

<telerik:RadGrid runat="server" ID="grid_AccessRecords"
    AllowPaging="True"
    AllowSorting="True"
    Visible="False" 
    Width="100%"
    PageSize="25" 
    OnItemCommand="AccessRecordsGridOnItemCommand"
    OnNeedDataSource="AccessRecordGridNeedDataSource">
    <PagerStyle Position="TopAndBottom" />
    <ClientSettings EnableRowHoverStyle="true" />  
    <MasterTableView DataKeyNames="Id" AutoGenerateColumns="False" EditMode="EditForms">
        <Columns>
            <telerik:GridTemplateColumn HeaderText="Eign" UniqueName="tmp_AccessGroup">
                <ItemTemplate>
                    <asp:label runat="server" ID="lbl_accessGroupName" Text='<%# Eval("AccessGroupName") %>' />
                </ItemTemplate>
                <EditItemTemplate>
                    <telerik:RadComboBox runat="server" ID="combo_editAccessGroup"></telerik:RadComboBox>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" EditText="edit" ButtonType="ImageButton" EditImageUrl="/_layouts/images/AFLSharepoint2010/Edit.gif" />
            <telerik:GridButtonColumn CommandName="Delete" Text="delete" ConfirmText="Are you sure?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete"
                ButtonType="ImageButton" UniqueName="DeleteColumn" ImageUrl="/_layouts/images/AFLSharepoint2010/Delete.gif" />
        </Columns>
        <EditFormSettings ColumnNumber="1" CaptionDataField="Id" CaptionFormatString="derp">
        EditColumn ButtonType="ImageButton" InsertText="Save" UpdateText="Save" UniqueName="EditCommandColumn" CancelText="Cancel" />
        </EditFormSettings>
    </MasterTableView>
</telerik:RadGrid>

The my cs file:

    protected void AccessRecordsGridOnItemCommand(object sender, GridCommandEventArgs e)
    {
        GridEditableItem editableItem = e.Item as GridEditableItem;

        if (editableItem != null)
        {
            RadComboBox comboEditAccessGroup = (RadComboBox) editableItem.FindControl("combo_editAccessGroup");
            //TODO: find out why always null???
        }
    }
4

1 回答 1

0

OnItemCreated如果您改用该方法,您应该能够访问您的组合框:

protected void AccessRecordsGrid_OnItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{

    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        //the item is in edit mode    
        GridEditableItem editedItem = e.Item as GridEditableItem;

        RadComboBox comboEditAccessGroup = (RadComboBox)editedItem.FindControl("combo_editAccessGroup");

    }
}
于 2013-01-25T02:19:55.573 回答