RadDropDownList invisible until clicked

4 posts, 1 answers
  1. Nate
    Nate avatar
    4 posts
    Member since:
    Apr 2014

    Posted 24 Apr 2014 Link to this post

    I'm using RadDropDownList inside a RadGrid. The RadDropDownList has its own sqlsource because it binds to a lookup table. It works somewhat fine and returns data, but whenever the ID value is 0 (a common case), the RadDropDownList does not display until I click on the space where it should be--then it appears. This seems like strange default behavior. Figuring the control was getting confused because of the cases of "0" IDs, I changed my query to the lookup table so that it would see 0 as a real value with the corresponding text "** Main Contract **". Even when I click the space where the ddl should be, and the ddl then appears, it still doesn't have "** Main Contract **" selected -- it is in the list though.

    How can I fix this so that (1) the RadDropDownList appears even when the value is 0; and (2) the "** Main Contract **" line item is selected when the value is 0.

    It seems like when the value for that ddl field is 0, rad wants to hide it. I attached 2 screenshots and my declarative code.

    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
                    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1">
                        <telerik:RadListBox runat="server" ID="SavedChangesList" Width="600px" Height="200px" Visible="false"></telerik:RadListBox>
                        <telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
                            AllowAutomaticInserts="True" PageSize="10" Skin="Default" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted"
                            OnItemUpdated="RadGrid1_ItemUpdated" OnPreRender="RadGrid1_PreRender" AllowAutomaticUpdates="True" AllowPaging="True"
                            AutoGenerateColumns="False" Width="950px" OnBatchEditCommand="RadGrid1_BatchEditCommand" DataSourceID="sqlContractMatrix">
                            <MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="ID" DataSourceID="sqlContractMatrix" HorizontalAlign="NotSet" EditMode="Batch" AutoGenerateColumns="False">
                                <BatchEditingSettings EditType="Cell" />
                                <SortExpressions>
                                    <telerik:GridSortExpression FieldName="SiteID,ProductID" SortOrder="Descending" />
                                </SortExpressions>
                                <Columns>
                                    <telerik:GridTemplateColumn HeaderText="Site" HeaderStyle-Width="150px" UniqueName="SiteID" DataField="SiteID">
                                        <ItemTemplate>
                                            <%# Eval("SiteName") %>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <telerik:RadDropDownList runat="server" ID="ddlSites" AppendDataBoundItems="true" DataValueField="SiteID" DataTextField="SiteName" DataSourceID="sqlSites">
                                                 
                                            </telerik:RadDropDownList>
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>
     
                                    <telerik:GridTemplateColumn HeaderText="Product" HeaderStyle-Width="150px" UniqueName="ProductID" DataField="ProductID">
                                        <ItemTemplate>
                                            <%# Eval("ProductName") %>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <telerik:RadDropDownList runat="server" ID="ddlProducts" DropDownWidth="250" DropDownHeight="400" DefaultMessage="Product" AppendDataBoundItems="true" DataValueField="ProductID" DataTextField="ProductName" DataSourceID="sqlProducts">
                                                 
                                            </telerik:RadDropDownList>
                                        </EditItemTemplate>
                                    </telerik:GridTemplateColumn>
                                     
                                     
                                    <telerik:GridBoundColumn DataField="TemplateFile" HeaderStyle-Width="200px" HeaderText="Template"
                                        SortExpression="TemplateFile" UniqueName="TemplateFile">
                                    </telerik:GridBoundColumn>
     
                                    <telerik:GridBoundColumn DataField="PDFName" HeaderStyle-Width="200px" HeaderText="PDFName"
                                        SortExpression="PDFName" UniqueName="PDFName">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridButtonColumn ConfirmText="Delete this record?" ConfirmDialogType="RadWindow"
                                        ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton"
                                        CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                    </telerik:GridButtonColumn>
                                </Columns>
                            </MasterTableView>
                        </telerik:RadGrid>
                    </telerik:RadAjaxPanel>
                    <asp:SqlDataSource ID="sqlContractMatrix" runat="server" ConnectionString="<%$ ConnectionStrings:FitTrack %>"
                        DeleteCommand="DELETE FROM ContractMatrix WHERE ID = @ID"
                        InsertCommand="INSERT INTO ContractMatrix (SiteID, ProductID, TemplateFile, PDFName, LastModifiedDate, LastModifiedByID) VALUES (@SiteID, @ProductID, @TemplateFile, @PDFName, @LastModifiedDate, @LastModifiedByID)"
                        UpdateCommand="UPDATE ContractMatrix SET SiteID = @SiteID, ProductID = @ProductID, TemplateFile = @TemplateFile, PDFName = @PDFName, LastModifiedDate = GETDATE(), LastModifiedByID = @LastModifiedByID WHERE ID = @ID">
                        <DeleteParameters>
                            <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="SiteID" Type="Int32"></asp:Parameter>
                            <asp:Parameter Name="ProductID" Type="Int32"></asp:Parameter>
                            <asp:Parameter Name="TemplateFile" Type="String"></asp:Parameter>
                            <asp:Parameter Name="PDFName" Type="String"></asp:Parameter>
                            <asp:Parameter Name="LastModifiedDate" Type="DateTime"></asp:Parameter>
                            <asp:Parameter Name="LastModifiedByID" Type="DateTime"></asp:Parameter>
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="SiteID" Type="Int32"></asp:Parameter>
                            <asp:Parameter Name="ProductID" Type="Int32"></asp:Parameter>
                            <asp:Parameter Name="TemplateFile" Type="String"></asp:Parameter>
                            <asp:Parameter Name="PDFName" Type="String"></asp:Parameter>
                            <asp:Parameter Name="LastModifiedDate" Type="DateTime"></asp:Parameter>
                            <asp:Parameter Name="LastModifiedByID" Type="DateTime"></asp:Parameter>
                            <asp:Parameter Name="ID" Type="Int32"></asp:Parameter>
                        </UpdateParameters>
                    </asp:SqlDataSource>
                     
                    <!-- SQL data sources for various lookup tables -->
                    <asp:SqlDataSource ID="sqlSites" runat="server" ConnectionString="<%$ ConnectionStrings:FitTrack %>" ProviderName="System.Data.SqlClient" SelectCommand="..."></asp:SqlDataSource>
                    <asp:SqlDataSource ID="sqlProducts" runat="server" ConnectionString="<%$ ConnectionStrings:FitTrack %>" ProviderName="System.Data.SqlClient"></asp:SqlDataSource>

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Apr 2014 in reply to Nate Link to this post

    Hi Nate,

    This is not an expected behavior. When the grid is in view mode, it will bind the value in ItemTemplate, here in your case its the ProductName. When you select the row, it goes to edit mode, then only the RadDropDownList values will be seen. Since the cells are empty on view mode means, there is no corresponding ProductName for that row. Please elaborate if this is not your issue. Meanwhile you can check the Batch Edit demo for understanding its functionality.

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nate
    Nate avatar
    4 posts
    Member since:
    Apr 2014

    Posted 25 Apr 2014 in reply to Princy Link to this post

    I have been working from the Batch Edit demo.

    There *is* a row for value of "0". It's just not displaying. Please help. Isn't there a way to force the DDL to display in all cases, and to show the selected item when value is 0?
  5. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Apr 2014 in reply to Nate Link to this post

    Hi Nate,

    If you want to display the dropdown in view mode as well as edit form you have to add the RadDropDownList to both ItemTemplate and EditItemTemplate as follows:

    ASPX:
    <telerik:GridTemplateColumn DataField="ProductID" UniqueName="ProductID" HeaderText="ProductName">
    <ItemTemplate>   
        <telerik:RadDropDownList runat="server" ID="ddlName" DataValueField="ProductID" DataTextField="ProductName" DataSourceID="SqlDataSource1" SelectedValue='<%# Bind("ProductID") %>' >
        </telerik:RadDropDownList>
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadDropDownList runat="server" ID="ddlEditName" AppendDataBoundItems="true" DataValueField="ProductID" DataTextField="ProductName" DataSourceID="SqlDataSource1">
        </telerik:RadDropDownList>
    </EditItemTemplate>
    </telerik:GridTemplateColumn>

    Or another suggestion is you can use the GridDropDownColumn:

    ASPX:
    <telerik:GridDropDownColumn UniqueName="ProductID" DataSourceID="SqlDataSource1" ListTextField="ProductName" ListValueField="ProductID" HeaderText="ProductName" DataField="ProductID" />

    Thanks,
    Princy
Back to Top