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

RadDropDownList invisible until clicked

3 Answers 99 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Nate
Top achievements
Rank 2
Nate asked on 24 Apr 2014, 09:19 PM
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>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Apr 2014, 11:37 AM
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
0
Nate
Top achievements
Rank 2
answered on 25 Apr 2014, 01:38 PM
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?
0
Accepted
Princy
Top achievements
Rank 2
answered on 28 Apr 2014, 05:32 AM
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
Tags
DropDownList
Asked by
Nate
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Nate
Top achievements
Rank 2
Share this question
or