從RadGrid內聯編輯時,我無法抓取RadComboBox。當我試圖通過這個GridEditableItem找到正確的控件時,我總是收到null。任何人都可以拋出一些關於如何從我的代碼中訪問RadCombobox的指針嗎?在RadGrid的代碼隱藏中訪問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>
我的CS文件:
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???
}
}
Telerik有一個很棒的網站,可以學習如何使用他們的控件如果你使用Telerik編碼,我建議你開始查看他們詳細記錄的頁面[Telerik RadComboBox](http://www.telerik.com/help/aspnet-ajax/combobox-templates-accessing-controls.html) – MethodMan