I went to add a ListView to a visual web part I had created and it didn't show up in Intellisense. I figured it was just a hiccup in the intellisense so I just typed it in manually but when I run the web part it throws the error:

Unknown server tag 'asp:ListView'

Is there a way to do this in a Web Part?


I am able to use a Repeater with is also part of the System.Web.UI.WebControl namespace as well as other controls belonging to this namespace .


It looks like the ListView control lives in the System.Web.UI.WebControls namespace, so you'll need to register that assembly in your markup. Add this to your markup.

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

Edit: Alternatively, you can add the following markup in the web.config so you don't have to register this on each page.

<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

More info

  • I am able to use the Repeater control which is also in System.Web.UI.WebControls. I also have access to numerous other controls that belong to System.Web.UI.WebControls. Regardless I gave this a shot and it did not work. – Abe Miessler May 17 '11 at 19:31
  • When you say it did not work, do you mean it would not build or it gave a runtime error? What was the error message? – Matt Weimer May 17 '11 at 19:36
  • Scratch that, it just wasn't showing up in intellisense. Not sure why that is, but the page no longer errors out. – Abe Miessler May 17 '11 at 19:46
  • Glad to see it works. Out of curiosity, which reference did you add? Page level or the web.config level? – Tim Gabrhel May 17 '11 at 20:05
  • 1
    I'd advocate not adding it to the web.config. Its more difficult to support for Admins and doesn't scale well to a multi-server farm. What happens if you added another WFE but forgot the web.config step? Many hours of trying to fix the problem. – Neil Richards May 17 '11 at 21:01

I would recommend either using a SPGridView and populating it or you can programmatically add a listview web part to the page when the feature is activated. That way you can control the properites of the ListView web part without having to mirror each of the properties that you are setting.

  • Very interesting, I will look into that. – Abe Miessler May 17 '11 at 20:23
  • 1
    SPGridView adds a filtering functionality, but it is a very buggy control, really. I've worked with it in two big projects at work. If you decide to use it, I recommend you to remember that it is a project potential risk. – Andrey Markeev May 17 '11 at 21:09
  • Good to know, thanks for the heads up. I'll probably stick with the ListView. – Abe Miessler May 18 '11 at 14:57

Actually ListViewWebPart is for internal usage only. I would recommend to use DataViewWebPart. It has almost the same functionality and it is officially recommended for data visualisation in cases where SPGrid is not enough.

  • Sorry, I'm actually using just the ListView not the ListViewWebPart. – Abe Miessler May 18 '11 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.