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

GridDropDownColumn in RadGrid : problem with databind

3 Answers 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yann
Top achievements
Rank 1
Yann asked on 14 Dec 2010, 12:02 PM

Hello,

I've got a trouble with dropdown column databinding in a RadGrid :
I've got 2 columns in my grid, one dropdown binded to a "Code" column, and one griddatabound column binded to a "Libelle" column
When I display the RadGrid, the "Code" column always display the first element of the dropdown column.
So the selected item in the drop down list is always the first element, not the data item.
When I am in edit mode, the dropdownlist is well binded.
Note that the RadGrid and The GridDropDown column are binded on objects of the same type.
Thanks for your help.
Here is my aspx code :

<%@ Control AutoEventWireup="false" CodeBehind="wucAdminEditions.ascx.vb" Inherits="FilsRSSInternes.wucAdminEditions" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
  
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
    <script language="javascript" type="text/javascript">
        function verifierSelectionEditions() {
            var grid = $find("<%=GrilleAdminEditions.ClientID %>");
            if (grid != null) {
                if (grid.get_selectedItems().length > 0) {
                    return true;
                } else {
                    alert('Aucune édition sélectionnée');
                    return false;
                }
            }
        }
    </script>
</telerik:RadScriptBlock>
<telerik:RadAjaxPanel ID="PanelEditions" runat="server" EnableAJAX="true">
    <div style="text-align:left;width:80%;padding:10px;">
        <asp:Label ID="lblMsg" runat="server" CssClass="MessageErreur"></asp:Label>
    </div>
    <div style="text-align:right;width:80%;padding:10px;">
        <telerik:RadGrid runat="server" ID="GrilleAdminEditions" ShowStatusBar="true" ShowHeader="true"
            AutoGenerateColumns="false" AllowSorting="true" AllowMultiRowSelection="true"
            EnableEmbeddedSkins="true" Width="100%" Skin="Windows7" SkinID="Windows7"
            AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true"
            PageSize="20" PagerStyle-AlwaysVisible="true" AllowPaging="true" 
            GroupingEnabled="false" ShowGroupPanel="false" 
            ClientSettings-AllowDragToGroup="false" ClientSettings-Selecting-AllowRowSelect="false"
            SortingSettings-SortToolTip="Cliquer pour trier la colonne" SortingSettings-SortedDescToolTip="Tri ascendant" SortingSettings-SortedAscToolTip="Tri descendant"
            DataSourceID="ListeEditionsADM"
            OnItemDataBound="GrilleAdminEditions_ItemDataBound">
                <MasterTableView runat="server" PageSize="20" NoMasterRecordsText="Aucun abonnement disponible pour les éditions de la mise à jour" NoDetailRecordsText="Aucun abonnement disponible pour les éditions de la mise à jour"
                        ShowHeadersWhenNoRecords="true"
                        AllowAutomaticDeletes="true"
                        AllowAutomaticInserts="true"
                        AllowAutomaticUpdates="true"
                        CommandItemDisplay="Top"
                        EditMode="InPlace"
                        AutoGenerateColumns="false"
                        DataSourceID="ListeEditionsADM"
                        >
                    <Columns>
                        <telerik:GridDropDownColumn HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" UniqueName="Code" DataField="Code" DataSourceID="ListeEditionsABO" ListTextField="Code" ListValueField="Code" DropDownControlType="DropDownList">
                        </telerik:GridDropDownColumn>
                        <telerik:GridBoundColumn HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" HeaderText="Titre" UniqueName="Libelle" DataField="Libelle">
                        </telerik:GridBoundColumn>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                        </telerik:GridEditCommandColumn>
                        <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                            ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                            UniqueName="DeleteColumn">
                            <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                        </telerik:GridButtonColumn>
                        <telerik:GridButtonColumn ButtonType="ImageButton" ItemStyle-HorizontalAlign="Center" UniqueName="imgAbonner">
                        </telerik:GridButtonColumn>
                    </Columns>
                </MasterTableView>
                <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric"
                    FirstPageText="" FirstPageToolTip="Aller à la première page"
                    NextPageText="" NextPageToolTip="Aller à la page suivante"
                    LastPageText="" LastPageToolTip="Aller à la dernière page"
                    PrevPageText="" PrevPageToolTip="Aller à la page précédente"
                    NextPagesToolTip="Afficher les pages suivantes" PrevPagesToolTip="Afficher les pages précédentes"
                    PagerTextFormat="{4}{5} édition(s) sur {1} page(s)"
                />
        </telerik:RadGrid>
    </div>
</telerik:RadAjaxPanel>
<asp:ObjectDataSource ID="ListeEditionsABO" runat="server" SelectMethod="GetListeEditionsABO" TypeName="FilsRSSInternes.EditionMAJ"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="ListeEditionsADM" runat="server" SelectMethod="GetListeEditionsADM" TypeName="FilsRSSInternes.EditionMAJ"></asp:ObjectDataSource>

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 14 Dec 2010, 04:05 PM
Hello Yann,

The TypeName property of the ObjectDataSource specifies the type of the object that will be used to fetch the collections of custom data objects. The DataObjectTypeName specifies the actual type of the data object RadGrid and the GridDropDownColumn bind to. Can you verify they are the same? I have created a test page with a similar scenario to try this out and the GridDropDownColumn seems to be binding OK. Attaching the test page for you to check out.

Greetings,
Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Yann
Top achievements
Rank 1
answered on 14 Dec 2010, 04:28 PM
Thanks for you answer.
Unfortunately, the item in the dropdown list is not selected to the value of the object field.
I set the TypeName and DataObjectTypeName to the same type (as FilsRSSInternes.EditionMAJ).
When I'm in edit mode, the dropdown is well filled but the selected item is always the first of the list.

I use the 2009 Q3 SP2 version of Telerik objects.
0
Veli
Telerik team
answered on 14 Dec 2010, 04:41 PM
Hi Yann,

I have tested this scenario with the RadControls version you have specified and it seems to be working OK. Attaching the test project I used.

Veli
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Yann
Top achievements
Rank 1
Answers by
Veli
Telerik team
Yann
Top achievements
Rank 1
Share this question
or