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

SharePoint 2010 populate DataGrid with list items error

1 Answer 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Maureen
Top achievements
Rank 1
Maureen asked on 17 Dec 2012, 04:32 PM
I am trying to create a User Control to place into a Telerik MegaMenu (RadMenu). The User Control is named "clientfilter" which will pull a sub-set of data from a SharePoint 2010 list. I have placed the following code into the "Page_Load" event but am getting errors on render.

protected void Page_Load(object sender, EventArgs e)
        {
            SPSite site = new SPSite("http://abcdev");
            using (SPWeb web = site.OpenWeb())
            {
                try
                {
                    SPList clientlist = web.Lists.TryGetList("clientmatter");
                    if (clientlist != null)
                    {
                        SPListItemCollection clientitems = clientlist.Items;
                        DataGrid dg = new DataGrid();
                        dg.DataSource = clientlist.Items.GetDataTable();
 
                        foreach (SPListItem clientitem in clientitems)
                        {
                            string clientddlvalue = clientitem["clientid"].ToString();
                            //myselect.Items.Add(clientddlvalue);
                             
                        }
                         
                        if ( !IsPostBack )
                         {
                           GridBoundColumn boundColumn;
 
                           //Important: first Add column to the collection
                           boundColumn = new GridBoundColumn();
                           this.RadGrid1.MasterTableView.Columns.Add(boundColumn);
 
                           //Then set properties
                           boundColumn.DataField = "clientid";
                           boundColumn.HeaderText = "clientid";
                         }
                    }
                }
                catch
                {
 
                }
                {
                    web.Dispose();
                }
            }
               
        }

The error I can see is "failure loading assembly 'Telerik.Web.UI.Design' ...", however, not sure if this is the real error or a by-product of a different error. When I originally entered the assembly registrations I mis-typed the name, however, I have subsequently fixed the name, but the error still persists. I have added the following to the GAC already:

  • Telerik.Web.UI
  • Telerik.Web.Design
  • Telerik.Web.UI.Skins

In my custom master page I have the following registrations:
<%@ Register Tagprefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI, Version=2012.3.1205.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" %>
<%@ Register Tagprefix="telerik" Namespace="Telerik.Web.Design" Assembly="Telerik.Web.Design, Version=2012.3.1205.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" %>

What am I missing? Why will the code not work?

Thank you in advance.

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 20 Dec 2012, 09:13 AM
Hello,

 You can make sure that you are referencing the same version of the assemblies everywhere in the application and also that the assemblies are added to the SafeControls collection in the web.config file. For more information can refer to this help topic.
Additionally for databinding RadGrid we recommend using the NeedDataSource event.

All the best,
Marin
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.
Tags
Grid
Asked by
Maureen
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or