5.1 sp1 module display choice value in datagrid

Posted by Community Admin on 04-Aug-2018 15:00

5.1 sp1 module display choice value in datagrid

All Replies

Posted by Community Admin on 09-Aug-2012 00:00

I added a choices field to my module and want to display the value of this in a datagrid on my .ascx file.

The module is called Mitarbeiter (employees). 

I found some related tables to this module on the database bud 

a) did not figure out how that works
b) where all possible values are stored
c) how to get the value to display in the grid

This is my code for the grid. The part in Question is called Funktion.

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" AllowSorting="True" ShowGroupPanel="True" >
    <ClientSettings AllowDragToGroup="True">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
        <telerik:GridBoundColumn DataField="Vorname" FilterControlAltText="Vorname" HeaderText="Vorname" UniqueName="Vorname">
        <telerik:GridBoundColumn DataField="Nachname" FilterControlAltText="Nachname" HeaderText="Nachname" UniqueName="Nachname">
        <telerik:GridBoundColumn DataField="Telefon" FilterControlAltText="Telefon" HeaderText="Telefon" UniqueName="Telefon">
        <telerik:GridBoundColumn DataField="Mail" FilterControlAltText="Email" HeaderText="E-Mail" UniqueName="Email">
        <telerik:GridBoundColumn DataField="Funktion" FilterControlAltText="Funktion" HeaderText="Funktion" UniqueName="Funktion">
        <telerik:GridBoundColumn DataField="Taetigkeit" FilterControlAltText="Taetigkeit" HeaderText="Tätigkeit" UniqueName="Taetigkeit">
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
<FilterMenu EnableImageSprites="False"></FilterMenu>

This is my codebehind

namespace SitefinityWebApp.UserControls
    public partial class mitarbeiter_liste : System.Web.UI.UserControl
        protected void Page_Load(object sender, EventArgs e)
            if (!Page.IsPostBack)
                // Fetch a collection of "live" and "visible" mitarbeiter items.
                var myCollection = GetDataItems();
                // Binds the collection of Person items to the RadGrid
                RadGrid1.DataSource = myCollection;
        // Gets a collection of "live" and "visible" mitarbeiter items.
        public IQueryable<DynamicContent> GetDataItems()
            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
            Type mitarbeiterType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Mitarbeiter.Mitarbeiter");
            // Fetch a collection of "live" and "visible" mitarbeiter items.
            var myCollection = dynamicModuleManager.GetDataItems(mitarbeiterType).Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Visible == true);
            return myCollection;

Any idea how I get the value of Funktion (see screenshot sf_funktion.png to display in the grid?

I could not find a table with all the possible values of the choise field. Any idea where they are stored, just out of curiosity. 

Answer: Looking a bit throu the tables I found sf_mb_dynamic_module_field where the values are  stored.


Posted by Community Admin on 13-Aug-2012 00:00

Hello Markus,

I've replied to the support thread you submitted on the same issue, however for your convenience I'm also pasting our reply below:

 RadGrid's databinding does not understand array types for column values.
ChoiceField persist the values in a String[] by default, so in order to achieve the desired functionality you can easily use a GridTemplateColumn:

<telerik:GridTemplateColumn HeaderText="Choice" >


                    <asp:Literal ID="Funktion" runat="server" />



 and then set the value of the control in your ItemTemplate on the server side:

void RGrdi1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)



           if (e.Item.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem || e.Item.ItemType == Telerik.Web.UI.GridItemType.Item)


               var functionColumn = e.Item.FindControl("Funktion") as Literal;

               var dataitem = e.Item.DataItem as DynamicContent;

               var choiceValue = dataitem.GetValue<String[]>("TestChoice");

               foreach (var item in choiceValue)


                   functionColumn.Text += item.ToString();




Please find attached a short sample demonstrating the implemented functionality, I hope you find this information useful.


All the best,
Boyan Barnev
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed