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

Enum datasource

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert Jakech
Top achievements
Rank 1
Robert Jakech asked on 08 May 2010, 08:56 AM
Hi there  i need help on binding enum to a radgrid.

I have enum below:
<div>&nbsp;<i>public enum UserType</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;{</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Default = 1, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Parameters = 2,</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Students = 3,</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Marks = 4,</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</i></div> 
and my radgrid defined as follows:
 
<div><i>&lt;telerik:RadGrid id="userGrid" runat="server" AllowFilteringByColumn="false" Width="100%" &nbsp;</i></div><div><i>&nbsp;&nbsp; &nbsp; AutoGenerateColumns="false" PageSize="30" AllowPaging="true"&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp;&lt;MasterTableView&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;Columns&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;telerik:GridTemplateColumn AllowFiltering="false" Resizable="true" UniqueName="value" HeaderText="Pages"&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ItemTemplate&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;asp:Label ID="asplabelValue" runat="server" ForeColor="Black" Text='&lt;% #Bind("enumValue") %&gt;' Font-Size="Medium"&gt;&lt;/asp:Label&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/ItemTemplate&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/telerik:GridTemplateColumn&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;telerik:GridTemplateColumn AllowFiltering="false" Resizable="true" UniqueName="pages" HeaderText="Pages"&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;ItemTemplate&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;asp:Label ID="aspPgesLabel" runat="server" ForeColor="Black" Font-Size="Medium" Text='&lt;% #Bind("enumText") %&gt;'&gt;&lt;/asp:Label&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/ItemTemplate&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/telerik:GridTemplateColumn&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/Columns&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/MasterTableView&gt;</i></div><div><i>&nbsp;&nbsp; &nbsp;&lt;/telerik:RadGrid&gt;</i></div
I need to set the datasource of the grid to the enum, and bind the enum name (text) and enum value as shown int he radgrid definition.

Please, someone help me with code snippets that can achieve this.

thanks.


1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 13 May 2010, 06:36 AM
Hi Robert,

Our system indicates that you have opened a duplicate post on the same issue:

http://www.telerik.com/community/forums/aspnet-ajax/grid/bind-radgrid-to-enum-datasource.aspx

To avoid redundant posts, we can continue any further communication there.

Sincerely yours,
Yavor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Robert Jakech
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or