Combobox inside edit item template not populating

2 posts, 1 answers
  1. Amit
    Amit avatar
    88 posts
    Member since:
    Sep 2010

    Posted 19 Mar 2011 Link to this post

    Hey there,

    i've a combobox inside griditem template column.I m using linq data source to populate this

    <telerik:GridTemplateColumn HeaderText="Product ID" HeaderStyle-Font-Bold="true"
                                    AllowFiltering="true" DataField="ProductID">
                                    <EditItemTemplate>
                                        <telerik:RadComboBox ID="RadCbProductIDEdit" Skin="Office2007" runat="server" MarkFirstMatch="true"
                                            AllowCustomText="true" DataValueField="ProductID" EmptyMessage="Please select a ProductID "
                                            DataTextField="ProductID" DataSourceID="LinqDataSource1" Height="100px">
                                        </telerik:RadComboBox>
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <telerik:RadComboBox ID="RadcbProductIDInsert" runat="server" Skin="Office2007" MarkFirstMatch="true"
                                            AllowCustomText="true" DataValueField="ProductID" EmptyMessage="Please select a ProductID "
                                            DataTextField="ProductID" DataSourceID="LinqDataSource1" Height="100px">
                                        </telerik:RadComboBox>
                                    </InsertItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="lblProductID" runat="server" Text='<%# Bind("ProductID") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle Font-Bold="True" />
                                </telerik:GridTemplateColumn>
     
     
    <asp:LinqDataSource ID="LinqDataSource1" runat="server"
                ContextTypeName="LPSFPrototypeScreens.tblProduct" EntityTypeName=""
                Select="new (ProductID)" TableName="tblProductFeatures" >
    also here ProductID is FK.
    what cud be the reason??...

    Thanks
    Amit
  2. Answer
    Elliott
    Elliott avatar
    392 posts
    Member since:
    May 2010

    Posted 21 Mar 2011 Link to this post

    I could be way off with this but doesn't the filling of a combo box have to be done explicitly?
    I do it in the code behind, on the ItemDataBound event handler
    Protected Sub gvVendor_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles gvVendor.ItemDataBound
        Dim dgItem As GridDataItem = Nothing
        Dim gefItem As GridEditFormItem = Nothing
        Dim geItem As GridEditableItem = Nothing
     
        If TypeOf e.Item Is IGridInsertItem Then
        ElseIf TypeOf e.Item Is GridDataItem Then
            dgItem = CType(e.Item, GridDataItem)
            FillInCheckBoxes(dgItem)
        End If
        If TypeOf e.Item Is GridEditableItem Then
            geItem = CType(e.Item, GridEditableItem)
            FillInRepGroups(geItem)
        End If
    End Sub
     
    Private Sub FillInRepGroups(ByVal geItem As GridEditableItem)
        Dim geManager As GridEditManager = Nothing
        Dim gddlEditor As GridDropDownListColumnEditor = Nothing
        Dim rcbRepGroup As RadComboBox
        Dim rcbItem As RadComboBoxItem = Nothing
        Dim ds As DataSet = Nothing
        Dim ws As CommonFunctions
     
        If geItem.IsInEditMode Then
        Else
            Exit Sub
        End If
        geManager = geItem.EditManager
        gddlEditor = CType(geManager.GetColumnEditor("RepGroup"), GridDropDownColumnEditor)
        rcbRepGroup = gddlEditor.ComboBoxControl
        ws = New CommonFunctions
        ds = ws.GetRepGroups
        rcbRepGroup.DataSource = ds.Tables(0)
        rcbRepGroup.DataValueField = "RepGroupsID"
        rcbRepGroup.DataTextField = "RepGroups"
        rcbRepGroup.DataBind()
        rcbItem = New RadComboBoxItem("Select One", 0)
        rcbRepGroup.Items.Insert(0, rcbItem)
    End Sub
    <telerik:RadGrid ID="gvVendor" runat="server" GridLines="None">
    <MasterTableView DataKeyNames="VendorID" AutoGenerateColumns="false" AllowSorting="true" AllowPaging="true" CommandItemDisplay="Top" EditMode="InPlace" >
    <Columns>
        <telerik:GridBoundColumn UniqueName="VendorID" DataField="VendorID" HeaderText="VendorID" ReadOnly="true" />
        <telerik:GridTemplateColumn UniqueName="VendorName" HeaderText="Vendor Name" HeaderStyle-Width="200px" >
        <ItemTemplate>
            <asp:Label ID="lblVendorName" Text='<%# Bind("VendorName") %>' runat="server" />
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadTextBox ID="rtbVendorName" Text='<%# Eval("VendorName") %>' runat="server" />
            <asp:RequiredFieldValidator ID="rfvVendorName" ControlToValidate="rtbVendorName" ErrorMessage="*" runat="server" />
        </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridBoundColumn UniqueName="LNSPrefix" DataField="LNSPrefix" HeaderText="LNSPrefix" />
        <telerik:GridBoundColumn UniqueName="KMSPrefix" DataField="KMSPrefix" HeaderText="KMSPrefix" />
        <telerik:GridCheckBoxColumn UniqueName="RepGroupFlag" HeaderText="Rep Group?" />
        <telerik:GridDropDownColumn UniqueName="RepGroup" DropDownControlType="RadComboBox" EnableEmptyListItem="True" EmptyListItemValue="0" EmptyListItemText="Select One" ListValueField="RepGroupID" ListTextField="RepGroups" HeaderText="Rep Group" />
        <telerik:GridCheckBoxColumn UniqueName="RegistrationFlag" HeaderText="Registration?" />
        <telerik:GridEditCommandColumn EditText="Edit" />                       
        <telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" Text="Delete" />
    </Columns>
    </MasterTableView>
    </telerik:RadGrid>
Back to Top