Hi.
I have a grid with one combobox and some numerice columns. In edit/insert mode it is not possible to choose any value from the combobox, the combobox is locked and i can not cancel either. (I have to reload the page to get out of the edit/insert mode.) I am using EnableAutomaticLoadOnDemand = true and fill up the combobox in the ItemDataBound events. The code i am using is:
var classCodes = new List<string>();
for (int i = 1; i < 10; i++)
{
classCodes.Add("B0" + i);
}
I have used equivalent code in another project without problem with loading the combobox. So i don't understand why it is not working. Some have any idea what i am doing wrong?
I have a grid with one combobox and some numerice columns. In edit/insert mode it is not possible to choose any value from the combobox, the combobox is locked and i can not cancel either. (I have to reload the page to get out of the edit/insert mode.) I am using EnableAutomaticLoadOnDemand = true and fill up the combobox in the ItemDataBound events. The code i am using is:
<telerik:RadGrid ID="RadGrid2" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowFilteringByColumn="True" AllowMultiRowSelection="True" AllowPaging="True" AllowSorting="True" DataSourceID="LinqDataSource1" GridLines="None" ondatabound="RadGrid1_DataBound" onitemdatabound="RadGrid1_ItemDataBound" onitemdeleted="RadGrid1_ItemDeleted" oniteminserted="RadGrid1_ItemInserted" onitemupdated="RadGrid1_ItemUpdated"> <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="Top" DataSourceID="LinqDataSource1" DataKeyNames="Id"> <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings> <Columns> <telerik:GridTemplateColumn DataField="Id" HeaderText="Gruppe" SortExpression="Id" UniqueName="Id" AutoPostBackOnFilter="True" ShowFilterIcon="false"> <FooterTemplate>Template footer</FooterTemplate><FooterStyle VerticalAlign="Middle" HorizontalAlign="Center" /> <ItemTemplate><%#DataBinder.Eval(Container.DataItem, "Id")%></ItemTemplate> <EditItemTemplate> <telerik:RadComboBox DataTextField="Id" DataValueField="Id" ID="RadComboBox1" HighlightTemplatedItems="true" EmptyMessage="Velg et element..." AllowCustomText="true" runat="server" Height="100px" Width="95px" SelectedValue='<%#Bind("Id") %>' AutoPostBack="true" EnableAutomaticLoadOnDemand="True"></telerik:RadComboBox> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridNumericColumn DataField="FEE" DataType="System.Double" HeaderText="Avgift" SortExpression="FEE" UniqueName="FEE"> </telerik:GridNumericColumn> <telerik:GridNumericColumn DataField="PBE" DataType="System.Double" HeaderText="PBE" SortExpression="PBE" UniqueName="PBE"> </telerik:GridNumericColumn> <telerik:GridEditCommandColumn CancelText="Avbryt" EditText="Endre" InsertText="Sett inn" UpdateText="Oppdater"> </telerik:GridEditCommandColumn> <telerik:GridButtonColumn CommandName="Delete" Text="Slett" UniqueName="column1"> </telerik:GridButtonColumn> </Columns> </MasterTableView> </telerik:RadGrid> <asp:LinqDataSource ID="LinqDataSource2" runat="server" OnInserting="GridDataSource_Inserting" ContextTypeName="Mobitech.Mtbs2InfoEasy.linq.Mtbs2InfoEasy_DataClassesDataContext" TableName="Groups" OrderBy="Id" Select="new (Id, FEE, PBE)"> </asp:LinqDataSource>protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e){ if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridDataInsertItem) { FillComboBoxWithClassCodes(e, "RadComboBox1"); SetColumnWidthInInsertMode(e); } else if (!(e.Item is GridDataInsertItem) && e.Item.IsInEditMode) {
FillComboBoxWithClassCodes(e, "RadComboBox1"); SetColumnWidthInEditMode(e); SetFocusOnField(e, "PBE"); }}private void FillComboBoxWithClassCodes(GridItemEventArgs e, string comboBoxName){ var editItem = (GridDataItem) e.Item; if (editItem == null) return; var comboBox = (RadComboBox) editItem.FindControl(comboBoxName); comboBox.Items.Clear();
for (int i = 1; i < 10; i++)
{
classCodes.Add("B0" + i);
}
foreach (var classCode in classCodes) { var item = new RadComboBoxItem(); item.Text = classCode; item.Value = classCode; comboBox.Items.Add(item); } comboBox.DataBind();}I have used equivalent code in another project without problem with loading the combobox. So i don't understand why it is not working. Some have any idea what i am doing wrong?