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

GridDropDownColumn & Binding to Non-foreign Key Columns

3 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard Weeks
Top achievements
Rank 2
Richard Weeks asked on 13 May 2011, 01:12 AM

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

3 Answers, 1 is accepted

Sort by
0
Accepted
Mira
Telerik team
answered on 18 May 2011, 11:23 AM
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.

0
Richard Weeks
Top achievements
Rank 2
answered on 18 May 2011, 11:45 PM
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
0
Mira
Telerik team
answered on 20 May 2011, 04:04 PM
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.

Tags
Grid
Asked by
Richard Weeks
Top achievements
Rank 2
Answers by
Mira
Telerik team
Richard Weeks
Top achievements
Rank 2
Share this question
or