RadGrid/DDL not Binding using L2S

Thread is closed for posting
2 posts, 0 answers
  1. 51A986E9-998D-4E51-9FFD-994619ADB5DB
    51A986E9-998D-4E51-9FFD-994619ADB5DB avatar
    24 posts
    Member since:
    Oct 2011

    Posted 07 Apr 2013 Link to this post

    Requirements

    RadControls version

     2011.2.712.40

    .NET version 4.5
    Visual Studio version 2012
    programming language c#
    browser support

    all browsers supported by RadControls

       

    PROJECT DESCRIPTION                                    
    Hello,

    I am using a RadGrid with a RadComboBox within a GridTemplateColumn as such:

     

    <telerik:GridTemplateColumn HeaderText="State" EditFormColumnIndex="2">
        <ItemTemplate>
            <%#DataBinder.Eval(Container.DataItem, "State")%>
        </ItemTemplate>
        <EditItemTemplate>
            <telerik:RadComboBox ID="selectState" runat="server" Skin="Web20" DataTextField="stateName" DataValueField="stateCode" />
        </EditItemTemplate>
    </telerik:GridTemplateColumn>

    I am Databinding using L2S like so:
    protected void RadGrid1_EditCommand(object source, GridCommandEventArgs e)
     {
     
         if (e.Item is GridEditableItem && e.Item.IsInEditMode)
         {
             GridEditableItem edititem = (GridEditableItem)e.Item;
             DropDownList ddlStates = (DropDownList)edititem.FindControl("selectState");
             ddlStates.DataSource = DbContext.States;
             ddlStates.DataTextField = "stateName";
             ddlStates.DataValueField = "stateCode";
             ddlStates.DataBind();
         }
     
    }

    When I run the project, the state bound item is correctly dispayed however once i edit the record, the RadComboBox does not bind to the data source. No errors are generated. Is it possible that the RadGrid1_EditCommand routine is not firing? Is it my data binding method. DbContext.States is derived from a Class Library project attached to this project.

    Assistance would be helpful.
  2. 272EA702-B83F-49DA-9608-0FBC5A6ECAEB
    272EA702-B83F-49DA-9608-0FBC5A6ECAEB avatar
    4017 posts
    Member since:
    Oct 2016

    Posted 10 Apr 2013 Link to this post

    Hello Tom,

    Please note that the CodeLibrary type of tickets are for our customers to send their suggestions for useful projects that could be uploaded as code libraries in our site. For any issues related to our controls please open a regular support ticket or start a forum thread so that we could address your issue accordingly.

    Greetings,
    Maria Ilieva
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.