Hi.
I have a grid with a GridTemplateColumn containing a combobox. I want the combobox to only be available when the grid is in insert mode. I use the following code:
But the problem is that sometimes the combobox is available in edit mode and othertimes is not, also the same for insert mode. Somebody who knows what i am doing wrong? I assume the if-test maybe is wrong...
The code for the grid only the columns:
I have a grid with a GridTemplateColumn containing a combobox. I want the combobox to only be available when the grid is in insert mode. I use the following code:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item.OwnerTableView.IsItemInserted && e.Item is GridDataInsertItem) { var column = (GridTemplateColumn)e.Item.OwnerTableView.GetColumnSafe("UserNumber"); column.ReadOnly = false; } if (!(e.Item is GridDataInsertItem) && e.Item.IsInEditMode) { var column = (GridTemplateColumn)e.Item.OwnerTableView.GetColumnSafe("UserNumber"); column.ReadOnly = true; } }But the problem is that sometimes the combobox is available in edit mode and othertimes is not, also the same for insert mode. Somebody who knows what i am doing wrong? I assume the if-test maybe is wrong...
The code for the grid only the columns:
<Columns> <telerik:GridTemplateColumn UniqueName="UserNumber" DataField="UserNumber" HeaderText="Bruker" SortExpression="UserNumber"> <ItemTemplate><%#DataBinder.Eval(Container.DataItem,"UserNumber")%></ItemTemplate> <EditItemTemplate> <telerik:RadComboBox DataTextField="UserNumber" DataValueField="UserNumber" EnableLoadOnDemand="True" ID="RadComboBox1" HighlightTemplatedItems="true" runat="server" SelectedValue='<%#Bind("UserNumber") %>' DataSourceID="MtUserLinqDataSource"> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "UserNumber") %> <%# DataBinder.Eval(Container.DataItem, "FirstName") %> <%# DataBinder.Eval(Container.DataItem, "LastName")%> </ItemTemplate> </telerik:RadComboBox></EditItemTemplate></telerik:GridTemplateColumn> <telerik:GridNumericColumn DataField="Account" HeaderText="Reskontro" UniqueName="Account"></telerik:GridNumericColumn><telerik:GridEditCommandColumn CancelText="Avbryt" EditText="Endre" InsertText="Sett inn" UpdateText="Oppdater"></telerik:GridEditCommandColumn> </Columns>
Ceci