Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

UPDATE:

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 .

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

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=3.5.0.0, 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=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

More info

share|improve this answer
    
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
show 1 more comment

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.

share|improve this answer
    
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
add comment

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.

share|improve this answer
    
Sorry, I'm actually using just the ListView not the ListViewWebPart. –  Abe Miessler May 18 '11 at 14:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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