GridDropDownColumn & Binding to Non-foreign Key Columns

4 posts, 1 answers
  1. Richard Weeks
    Richard Weeks avatar
    95 posts
    Member since:
    Oct 2009

    Posted 12 May 2011 Link to this post

    Hello,

    Imagine two tables, each with two columns.

    Operations
     UserId
     StartedBy

     

    Users 
     Id 
     UserName

    Operations.UserId is a FK to Users.Id. All columns are integers.

    This works:

    <telerik:GridDropDownColumn 
        DataField="UserId" 
        DataSourceID="UsersDataSource" 
        HeaderText="UserId"
        ListTextField="UserName" 
        ListValueField="Id"  
        UniqueName="UserId">
    </telerik:GridDropDownColumn>

     

    This doesn't:

    <telerik:GridDropDownColumn 
        DataField="StartedBy" 
        DataSourceID="UsersDataSource" 
        HeaderText="Started By"
        ListTextField="UserName" 
        ListValueField="Id"  
        UniqueName="StartedBy">
    </telerik:GridDropDownColumn>

    Here's the DataSource:

    <asp:EntityDataSource 
        ID="UsersDataSource" 
        runat="server" 
        ConnectionString="name=MyEntities" 
        DefaultContainerName="MyEntities" 
        EnableFlattening="False" 
        EntitySetName="Users" 
        EntityTypeFilter="User" 
        OrderBy="it.[UserName]">
    </asp:EntityDataSource>

    I know the UserId works because it is a foreign key but the second "StartedBy" is just a normal Int32 column in the Db that I have no control over (i.e. no relationship is or will be defined).

    Normally, I'd just shrug and roll some code-behind but I'd much rather solve this in the declarative manner.

    What is the simplest way I can get my StartedBy dropdown to bind via the value recorded in Operations.StartedBy?

     
    Richard

  2. Answer
    Mira
    Admin
    Mira avatar
    1124 posts

    Posted 18 May 2011 Link to this post

    Hello Richard,

    I am afraid that the desired functionality cannot be achieved only declaratively.
    Please use the approach from the Customize/Configure GridDropDownColumn  help topic in order to access and configure the datasource of the drop-down in the code-behind.

    I hope this helps.

    Best wishes,
    Mira
    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Richard Weeks
    Richard Weeks avatar
    95 posts
    Member since:
    Oct 2009

    Posted 18 May 2011 Link to this post

    Thanks for that, I'll roll the code behind.

    May I humbly request the ability to label columns as pseudo foreign keys be added as a feature?

    Richard
  5. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 20 May 2011 Link to this post

    Hello Richard,

    I have forwarded your suggestion to our developers team and they will consider implementing in future versions of RadControls for ASP.NET AJAX.

    Kind regards,
    Mira
    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.

Back to Top