This is a migrated thread and some comments may be shown as answers.

Combobox inside edit item template not populating

1 Answer 119 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 19 Mar 2011, 11:19 AM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Elliott
Top achievements
Rank 2
answered on 21 Mar 2011, 04:48 PM
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>
Tags
ComboBox
Asked by
Amit
Top achievements
Rank 1
Answers by
Elliott
Top achievements
Rank 2
Share this question
or