Hello,
I currently have a rad grid that on row insert and edit command displays a regular ASP DropDownList box populated from code behind in the OnItemDataBound event handler. Everything is working fine, the values are populated and the data is stored on insert/update, however changing the EditMode to InPlace on the master table view creates an empty box with no data populated. What is changing here?
Here is the first part of my ASP for the grid
And here is the relevant code-behind
If I remove EditMode="InPlace" from the MasterTableView things work perfectly. Why the difference?
Thanks
I currently have a rad grid that on row insert and edit command displays a regular ASP DropDownList box populated from code behind in the OnItemDataBound event handler. Everything is working fine, the values are populated and the data is stored on insert/update, however changing the EditMode to InPlace on the master table view creates an empty box with no data populated. What is changing here?
Here is the first part of my ASP for the grid
<telerik:RadGrid ID="OrderItemGrid" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None"> <MasterTableView CommandItemDisplay="Top" DataKeyNames="OrderItemID" EditMode="InPlace"> <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Quick-Add New Order Item" /> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True"> </RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True"> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="OrderItemID" FilterControlAltText="Filter OrderItemID column" HeaderText="Item ID" ReadOnly="True" UniqueName="OrderItemID"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn DataField="CatID" FilterControlAltText="Filter CatID column" HeaderText="Category" UniqueName="CatID"> <EditItemTemplate> <asp:DropDownList ID="DDCategory" runat="server"></asp:DropDownList> </EditItemTemplate> <InsertItemTemplate> <asp:DropDownList ID="DDCategory" runat="server"></asp:DropDownList> </InsertItemTemplate> <ItemTemplate> <asp:Label ID="CatIDLabel" runat="server" Text='<%# Eval("CatID") %>'></asp:Label> </ItemTemplate> </telerik:GridTemplateColumn>And here is the relevant code-behind
Protected Sub OrderItemGrid_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles OrderItemGrid.ItemDataBound If TypeOf (e.Item) Is GridEditFormInsertItem And e.Item.IsInEditMode Then Dim editItem As GridEditFormInsertItem = CType(e.Item, GridEditFormInsertItem) Dim dropList As DropDownList = CType(editItem("CatID").FindControl("DDCategory"), DropDownList) Using dbContext As New MatrixORMModelVB() dropList.DataSource = dbContext.Categories.ToList() dropList.DataTextField = "CategoryName" dropList.DataValueField = "CategoriesID" dropList.DataBind() End Using ElseIf TypeOf (e.Item) Is GridDataItem And Not e.Item.IsInEditMode Then Dim editItem As GridDataItem = CType(e.Item, GridDataItem) Dim label As Label = CType(editItem("CatID").FindControl("CatIDLabel"), Label) Using dbContext As New MatrixORMModelVB() Dim temp As String = label.Text Dim tempCat As MatrixORM.Category = dbContext.Categories.Where(Function(c) c.CategoriesID = temp).First() label.Text = tempCat.CategoryName End Using End IfEnd SubIf I remove EditMode="InPlace" from the MasterTableView things work perfectly. Why the difference?
Thanks