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

GridDropDownColumn not working (no data in read-only or edit mode)

4 Answers 157 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jerry T.
Top achievements
Rank 1
Jerry T. asked on 08 Oct 2010, 03:04 PM
I have a basic grid that I want to allow InPlace editing of a few columns (I will later add an Edit Form to allow for full editing but, for now, this is it).  One of the columns of the grid I want to be a GridDropDownColumn and default it to display the current data and switch to a dropdownlist in Edit mode (again, using InPlace editing) and I want the default selected value to be the current value.

I've been through every demo and sample I could find in Telerik's document but I cannot get the GridDropDownColumn to do ANYTHING. No data shows up for it and no dropdown ever shows when I click the down arrow.  I finally at least got some data to display by falling back to a GridTemplateColumn and putting in an asp:DropDownList control in the EditItemTemplate.  Here is the ASPX:

<asp:ObjectDataSource ID="odsGetTaskStartTimes" runat="server" TypeName="DMCproWebApp.BALHelper" SelectMethod="GetTaskStartTimes" />
<asp:ObjectDataSource id="odsGetProgramServicesFast" runat="server" TypeName="DMCproWebApp.BALHelper" SelectMethod="GetProgramServicesFast">
    <SelectParameters>
        <asp:ControlParameter Name="ProgramNumber" ControlID="hiddenProgramListValue" PropertyName="Value" DbType="String" />
    </SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="odsGetProgramServiceTypes" runat="server" TypeName="DMCproWebApp.BALHelper" SelectMethod="GetProgramServiceTypes" />
   
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="radgrdProgramServicesFast">
            <UpdatedControls><telerik:AjaxUpdatedControl ControlID="radgrdProgramServicesFast" LoadingPanelID="RadAjaxLoadingPanel1"/></UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<div class="GridViewContainer" style="width:944px;">
    <telerik:RadGrid ID="radgrdProgramServicesFast" runat="server" Width="942px" DataSourceID="odsGetProgramServicesFast" EnableLinqExpressions="true"
        EnableEmbeddedSkins="false" Skin="DMCpro" ShowStatusBar="true"
        AutoGenerateColumns="false" AllowFilteringByColumn="false" AllowPaging="false" AllowSorting="true">
        <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" Scrolling-AllowScroll="true" Scrolling-ScrollHeight="280px" />
        <GroupingSettings CaseSensitive="false" />
        <MasterTableView TableLayout="Fixed" DataKeyNames="ProgramNumber,fldVenue,LineNumber,ItemNumber,OfficeLocation,ProgramLocation,ProgramStartDate,fldStatus,fldTruckLoadIn,AddToSchedule,fldAddtoContract,CustomerID,Description,RFPCount" EditMode="InPlace">
            <ItemStyle Font-Size="Small" Wrap="false" />
            <AlternatingItemStyle Font-Size="Small" Wrap="false" />
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="46px" EditImageUrl="~/img/Edit16x16.png" UpdateImageUrl="../img/Save16x16.png" CancelImageUrl="../img/Cancel16x16.png" />
                <telerik:GridImageColumn UniqueName="RFP" ImageUrl="~/img/Check-16x16.png" HeaderText="RFP" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="22px"
                    HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" />
                <telerik:GridBoundColumn DataField="fldTruckLoadIn" HeaderText="Sort" SortExpression="fldTruckLoadIn" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="35px" HeaderStyle-HorizontalAlign="Left" AllowFiltering="false" />
                <telerik:GridCheckBoxColumn DataField="AddToSchedule" HeaderText="QS" SortExpression="AddToSchedule" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="25px" HeaderStyle-HorizontalAlign="Left" AllowFiltering="false" />
                <telerik:GridCheckBoxColumn DataField="fldAddToContract" HeaderText="Add" SortExpression="fldAddToContract" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="25px" HeaderStyle-HorizontalAlign="Left" AllowFiltering="false" />
                <telerik:GridBoundColumn DataField="Description" HeaderText="Title" SortExpression="Description" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="135px" HeaderStyle-HorizontalAlign="Left" AllowFiltering="false" />
                <telerik:GridTemplateColumn HeaderText="Service" UniqueName="ServiceType" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="175px" HeaderStyle-HorizontalAlign="Left" AllowFiltering="false">
                    <ItemTemplate>
                        <%#DataBinder.Eval(Container.DataItem, "ServiceType")%>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddlProgramServiceTypes" runat="server" Width="175px"
                            DataSourceID="odsGetProgramServiceTypes" DataTextField="fldService" DataValueField="fldServiceID" /> 
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridDropDownColumn DataField="ServiceType" DataSourceID="odsGetProgramServiceType"
                    HeaderText="Service 2" ListTextField="fldservice" ListValueField="fldServiceID"
                    UniqueName="Service2" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="175px" >
                </telerik:GridDropDownColumn>  
                <telerik:GridBoundColumn DataField="StartDate" HeaderText="Start Date" SortExpression="StartDate" DataFormatString="{0:MM/dd/yyyy}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="75px" HeaderStyle-HorizontalAlign="Left" AllowFiltering="false" ReadOnly="true" />
                <telerik:GridBoundColumn DataField="EndTime" HeaderText="Ends" SortExpression="EndTime" DataFormatString="{0:MM/dd/yyyy}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="75px" HeaderStyle-HorizontalAlign="Left" AllowFiltering="false" ReadOnly="true" />
                <telerik:GridBoundColumn DataField="LineTotal" HeaderText="Service Total" SortExpression="LineTotal" UniqueName="LineTotal" DataFormatString="{0:c}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="90px" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Right" ReadOnly="true" />
                <telerik:GridBoundColumn DataField="fldServiceVenue" HeaderText="Costing Sheet" SortExpression="fldServiceVenue" UniqueName="fldServiceVenue" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="175px" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" ReadOnly="true" />
                <telerik:GridBoundColumn DataField="Cost" Visible="false" ReadOnly="true" />
                <telerik:GridBoundColumn DataField="fldVenue" Visible="false" ReadOnly="true" />
                <telerik:GridBoundColumn DataField="LineNumber" Visible="false" ReadOnly="true" />
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
</div>


Codebehind:
Private Sub radgrdProgramServicesFast_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles radgrdProgramServicesFast.ItemDataBound
    If (TypeOf e.Item Is GridDataItem) Then
        Dim gdi As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim LineTotal As String = Replace(gdi.Item("LineTotal").Text, " ", "0")
        Dim Cost As String = Replace(gdi.Item("Cost").Text, " ", "0")
        Dim chkQS As CheckBox = DirectCast(gdi.Item("AddToSchedule").Controls(0), CheckBox)
        Dim chkAdd As CheckBox = DirectCast(gdi.Item("fldAddToContract").Controls(0), CheckBox)
        m_Proposed += CDec(IIf(LineTotal = String.Empty, 0, LineTotal)) + CDec(IIf(Cost = String.Empty, 0, Cost))
        m_QS += CDec(IIf(chkQS.Checked, LineTotal, 0))
        m_Total += CDec(IIf(chkAdd.Checked, LineTotal, 0))
        Dim RFPCount As Integer = CInt(radgrdProgramServicesFast.MasterTableView.DataKeyValues(e.Item.ItemIndex)("RFPCount"))
        If (RFPCount = 0) Then
            Dim img As Image = DirectCast(gdi.Item("RFP").Controls(0), Image)
            img.Visible = False
        End If
        Dim cp As ContentPlaceHolder = Page.Form.FindControl("MasterContentPlaceHolder")
        Dim status As Integer = DirectCast(cp.FindControl("ddlProgramStatus"), DropDownList).SelectedValue
        If (gdi.EditFormItem IsNot Nothing) Then
            If (status <> 22) Then
                gdi.Item("btnEditService").Visible = True
            ElseIf (status = 22) And Roles.IsUserInRole(Permissions.Programs_Change_Sold_Invoiced) Then
                gdi.Item("btnEditService").Visible = True
            Else
                gdi.Item("btnEditService").Visible = False
            End If
        End If
    End If
End Sub

4 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 09 Oct 2010, 06:56 AM
Hello Jerry T.,

I think you have a typing error in the name of the ObjectDataSource for the GridDropDownColumn (for the DropDownList the name is correct that's why it retrieves the data)
<EditItemTemplate>
                            <asp:DropDownList ID="ddlProgramServiceTypes" runat="server" Width="175px" DataSourceID="odsGetProgramServiceTypes"
                                DataTextField="fldService" DataValueField="fldServiceID" />
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridDropDownColumn DataField="ServiceType" DataSourceID="odsGetProgramServiceType"
                        HeaderText="Service 2" ListTextField="fldservice" ListValueField="fldServiceID"
                        UniqueName="Service2" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="175px">
                    </telerik:GridDropDownColumn>




Sincerely yours,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jerry T.
Top achievements
Rank 1
answered on 11 Oct 2010, 01:31 PM
Hello, Marin.

Yes, that was an obvious typo that I'm not sure how it occurred as I'd copy and pasted the datasourceid.  Anyway, all I'm getting now is what I was getting in my first try at this.  I see the default value show up as a label when the grid first displays and then, when I go into EditMode, I see the same data there and an arrow for the GridDropDownColumn but clicking on the arrow does nothing. It's like it's either lost all the data or it's in some sort of read-only/disabled mode and that's the result I keep getting no matter how I approach using a GridDropDownColumn or a GridTemplateColumn with a RadComboBox.

The only way I can get this working is falling back to a GridTemplateColumn and use the regular asp:DropDownList control. Every example and demo I've found on Telerik's site results in the same thing. I just can't get the dropdown to do anything once I'm in EditMode.
0
Marin
Telerik team
answered on 12 Oct 2010, 04:04 PM
Hi Jerry T.,

I ran your code (changing the datasource with sample one and turning off the custom skin) and it worked as expected with the GridDropDownColumn. Can you please verify at your side that the datasources are set correctly (including their select methods return the right data) and the dropdown column and its DataSource, DataField, ListTextField and ListValueField properties are set as expected? Also check whether the problem is not in the custom skin (temporary switch it off and see if the problem persist). Here is the code that worked on my side (I used Northwind sample database):

<asp:ScriptManager ID="ScriptManager1" runat="server">
     </asp:ScriptManager>
    <asp:ObjectDataSource ID="odsGetProgramServicesFast" runat="server" TypeName="DMCproWebApp.BALHelper"
        SelectMethod="GetProgramServicesFast">
        <%--<SelectParameters>
            <asp:ControlParameter Name="ProgramNumber" ControlID="hiddenProgramListValue" PropertyName="Value"
                DbType="String" />
        </SelectParameters>--%>
    </asp:ObjectDataSource>
    <asp:ObjectDataSource ID="odsGetProgramServiceTypes" runat="server" TypeName="DMCproWebApp.BALHelper"
        SelectMethod="GetProgramServiceTypes" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="radgrdProgramServicesFast">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="radgrdProgramServicesFast" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div class="GridViewContainer" style="width: 944px;">
        <telerik:RadGrid ID="radgrdProgramServicesFast" runat="server" Width="942px" DataSourceID="SqlDataSource1"
            EnableLinqExpressions="true"  ShowStatusBar="true"
            AutoGenerateColumns="false" AllowFilteringByColumn="false" AllowPaging="false"
            AllowSorting="true">
            <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" Scrolling-AllowScroll="true"
                Scrolling-ScrollHeight="280px" />
            <GroupingSettings CaseSensitive="false" />
            <MasterTableView TableLayout="Fixed" DataKeyNames="ProductName"
                EditMode="InPlace">
                <ItemStyle Font-Size="Small" Wrap="false" />
                <AlternatingItemStyle Font-Size="Small" Wrap="false" />
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-CssClass="radGridViewHeader"
                        HeaderStyle-Width="46px" EditImageUrl="~/img/Edit16x16.png" UpdateImageUrl="../img/Save16x16.png"
                        CancelImageUrl="../img/Cancel16x16.png" />
                    <telerik:GridImageColumn UniqueName="RFP" ImageUrl="~/img/Check-16x16.png" HeaderText="RFP"
                        HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="22px" HeaderStyle-HorizontalAlign="Left"
                        ItemStyle-HorizontalAlign="Left" />
                    <telerik:GridBoundColumn DataField="ProductName" HeaderText="Sort" SortExpression="ProductName"
                        HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="35px" HeaderStyle-HorizontalAlign="Left"
                        AllowFiltering="false" />
                    <telerik:GridCheckBoxColumn DataField="Discontinued" HeaderText="QS" SortExpression="Discontinued"
                        HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="25px" HeaderStyle-HorizontalAlign="Left"
                        AllowFiltering="false" />
                    <telerik:GridCheckBoxColumn DataField="Discontinued" HeaderText="Add" SortExpression="Discontinued"
                        HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="25px" HeaderStyle-HorizontalAlign="Left"
                        AllowFiltering="false" />
                    <telerik:GridBoundColumn DataField="UnitPrice" HeaderText="Title" SortExpression="UnitPrice"
                        HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="135px" HeaderStyle-HorizontalAlign="Left"
                        AllowFiltering="false" />
                    <telerik:GridTemplateColumn HeaderText="Service" UniqueName="ServiceType" HeaderStyle-CssClass="radGridViewHeader"
                        HeaderStyle-Width="175px" HeaderStyle-HorizontalAlign="Left" AllowFiltering="false">
                        <ItemTemplate>
                            <%# DataBinder.Eval(Container.DataItem, "CategoryID")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="ddlProgramServiceTypes" runat="server" Width="175px" DataSourceID="SqlDataSource2"
                                DataTextField="CategoryName" DataValueField="CategoryID" />
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridDropDownColumn DataField="CategoryID" DataSourceID="SqlDataSource2"
                        HeaderText="Service 2" ListTextField="CategoryName" ListValueField="CategoryID"
                        UniqueName="Service2" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="175px">
                    </telerik:GridDropDownColumn>
                    <%--<telerik:GridBoundColumn DataField="StartDate" HeaderText="Start Date" SortExpression="StartDate"
                        DataFormatString="{0:MM/dd/yyyy}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="75px"
                        HeaderStyle-HorizontalAlign="Left" AllowFiltering="false" ReadOnly="true" />
                    <telerik:GridBoundColumn DataField="EndTime" HeaderText="Ends" SortExpression="EndTime"
                        DataFormatString="{0:MM/dd/yyyy}" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="75px"
                        HeaderStyle-HorizontalAlign="Left" AllowFiltering="false" ReadOnly="true" />
                    <telerik:GridBoundColumn DataField="LineTotal" HeaderText="Service Total" SortExpression="LineTotal"
                        UniqueName="LineTotal" DataFormatString="{0:c}" HeaderStyle-CssClass="radGridViewHeader"
                        HeaderStyle-Width="90px" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Right"
                        ReadOnly="true" />
                    <telerik:GridBoundColumn DataField="fldServiceVenue" HeaderText="Costing Sheet" SortExpression="fldServiceVenue"
                        UniqueName="fldServiceVenue" HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="175px"
                        HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" ReadOnly="true" />
                    <telerik:GridBoundColumn DataField="Cost" Visible="false" ReadOnly="true" />
                    <telerik:GridBoundColumn DataField="fldVenue" Visible="false" ReadOnly="true" />--%>
                    <telerik:GridBoundColumn DataField="UnitsInStock" Visible="false" ReadOnly="true" />
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
     <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
         ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
           
         SelectCommand="SELECT [ProductName], [CategoryID], [UnitsInStock], [UnitPrice], [Discontinued] FROM [Products]"></asp:SqlDataSource>
     <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
         ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
         SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]"></asp:SqlDataSource>


Regards,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jerry T.
Top achievements
Rank 1
answered on 12 Oct 2010, 05:25 PM
Marin,

I just installed the 2010.929 update and it's now magically working with the code above. 

That update also fixed another bug I was about to make a thread about where I could click on a row to select it but then the grid was in a type of read-only mode and clicking anywhere on the grid resulting in no events firing (other than column headers for sorting0


Thanks for the assistance, though.

Jerry
Tags
Grid
Asked by
Jerry T.
Top achievements
Rank 1
Answers by
Marin
Telerik team
Jerry T.
Top achievements
Rank 1
Share this question
or