RadGrid Drop Down List will not Bind

1 posts, 0 answers
  1. Perry
    Perry avatar
    50 posts
    Member since:
    Jul 2015

    Posted 04 Jan Link to this post

    I have 2 ASPX pages that use the same simple Telerik RadGrid.  Here is my ASP code for these RadGrids:

    <div id="GridViewArea" style="border-style: solid; border-width:0px; margin-top: 10px; width: 600px;">
                    <telerik:RadGrid ID="RadGrid1" runat="server"
                            NoMasterRecordsText="No Rides have been recorded for this rider."
                                <telerik:GridBoundColumn HeaderText="RiderID" DataField="RiderID" ReadOnly="true" Visible="false"></telerik:GridBoundColumn>
                                <telerik:GridTemplateColumn UniqueName="DateTemplateColumn" HeaderText="Ride Date">
                                        <asp:Label ID="DateEditItemTemplate" runat="server"
                                            Text='<%# DataBinder.Eval(Container.DataItem, "RideDate","{0:MM/dd/yyyy}") %>'>
                                        <telerik:RadDatePicker ID="dpRideDate" UniqueName="dpRideDate" DateInput-DateFormat="MM/dd/yyyy" MinDate="1999/1/1" runat="server" DbSelectedDate='<%# Bind("RideDate") %>'>
                                <telerik:GridTemplateColumn UniqueName="DeputyTemplateColumn" HeaderText=" Deputy">
                                        <asp:Label ID="DeputyEditItemTemplate" runat="server"
                                            Text='<%# DataBinder.Eval(Container.DataItem, "Deputy") %>'>
                                        <asp:DropDownList ID="ddlDeputy" runat="server" UniqueName="ddlDeputy" DataTextField="Name" DataValueField="EID" />
                                <telerik:GridTemplateColumn UniqueName="SectorColumn" HeaderText="Sector">
                                        <asp:Label ID="SectorEditItemTemplate" runat="server"
                                            Text='<%# DataBinder.Eval(Container.DataItem, "SectorDescription") %>'>
                                        <asp:DropDownList ID="ddlSector" runat="server" UniqueName="ddlSector" DataTextField="SectorDescription" DataValueField="SectorValue" />


    Note the RadGrid is within an asp:UpdatePanel

    I have 2 DropDown Lists used to add a new record to the grid and I bind these DropDown Lists in the RadGrid1_ItemDataBound Method here is that code:


    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
                if (e.Item is GridEditableItem && e.Item.IsInEditMode)
                    using (var db = new RideTracker2018Entities())
                        var sectors = (from c in db.LU_Sectors
                                       select new { c.SectorDescription, c.SectorValue }).ToList();
                        GridEditableItem item = e.Item as GridEditableItem;
                        // access/modify the edit item template settings here
                        DropDownList list = item.FindControl("ddlSector") as DropDownList;
                        list.DataTextField = "SectorDescription";
                        list.DataValueField = "SectorValue";
                        list.DataSource = sectors;
                        var deputies = (from c in db.VW_DeputyInfo
                                        select new { c.Name, c.EID }).ToList();
                        GridEditableItem item2 = e.Item as GridEditableItem;
                        DropDownList list2 = item2.FindControl("ddlDeputy") as DropDownList;
                        list2.DataTextField = "Name";
                        list2.DataValueField = "EID";
                        list2.DataSource = deputies;


    The grid renders and works as planned on one page but on the second page the DDDLs will not bind.  On the second page the code to bind the lists does not run because it fails to pass the if (e.Item is GridEditableItem && e.Item.IsInEditMode).

    Can anyone explain why these identical RadGrids are not working the same?

Back to Top