C# 从RadGrid访问codebehind中的RadComboBox

C# 从RadGrid访问codebehind中的RadComboBox,c#,asp.net,sharepoint-2010,telerik,telerik-grid,C#,Asp.net,Sharepoint 2010,Telerik,Telerik Grid,从RadGrid内联编辑时,我在抓取RadComboBox时遇到问题。当我试图通过这个GridEditableItem找到正确的控件时,我总是收到null。有人能给我一些关于如何从下面的代码访问RadCombobox的提示吗 我的ascx.cs文件: <telerik:RadGrid runat="server" ID="grid_AccessRecords" AllowPaging="True" AllowSorting="True" Visible="False

从RadGrid内联编辑时,我在抓取RadComboBox时遇到问题。当我试图通过这个GridEditableItem找到正确的控件时,我总是收到null。有人能给我一些关于如何从下面的代码访问RadCombobox的提示吗

我的ascx.cs文件:

<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>

如果改用
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");

    }
}

Telerik有一个很好的网站,可以学习如何使用他们的控件如果你使用Telerik编码,我建议你开始查看他们的文档化页面谢谢你的回答@Kwin,因为现在我可以抓住我的RadComboBox:)我有一个问题,奇怪的是,使用上面的方法,我可以毫无问题地抓取RadTextBox,但是当我尝试抓取RadComboBox时,我总是收到null。你知道为什么吗?@gardarvalur我不太清楚为什么RadTextBox可以工作,但RadComboBox不能。有两个Telerik演示,似乎表明文本框应该更容易处理。也许文本框是在更高级的控件(如组合框)之前在页面中创建的?
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");

    }
}