Wednesday, 11 July 2012

Error in using list view control in SharePoint 2010 visual webpart

Hi Tried to add a list view control in the SharePoint 2010 visual webpart but it give the error like following.


Line 8:  <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="BlogListUserControl.ascx.cs" Inherits="BlackintonWebparts.BlogList.BlogListUserControl" %>
Line 9: 
Line 10: <asp:ListView ID="ListViewProducts" runat="server" ItemPlaceholderID="ProductItem">
Line 11:     <ItemTemplate>
Line 12:

After that I found the namespace is not register so I register the name space

Add the following code under the <controls> section under <system.web> and pages in the webcofig file
 
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />



Or add in the ascx file or aspx file



<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>


Happy coding :))