Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

SPView change columns programmatically

  Asked By: Marcella    Date: Oct 08    Category: Sharepoint    Views: 3455

I created a little webpart and use ToolPaneView=2 to place it on the
list page of the view in which I am attempting to edit. It lets you
choose which columns should be shown. When using view.ViewFields.Delete
(col name) then view.Update() nothing happens to the view even after
refreshes. Can I not programmatically edit the views that are created
using the built in form?



2 Answers Found

Answer #1    Answered By: Freddy Heath     Answered On: Oct 08

If I’m reading this correctly you’re changing a view  after a ListViewWebPart has been created  from it. If that’s the case then there’s a special hidden view that it’s using to display the data. If you can get to that view you should be able to update  the display. You can get the DWP for a ListViewWebPart (it’s broken in the user interface but not from the API). From there you can extract the GUID for the view that it uses.

Answer #2    Answered By: Joanna Dixon     Answered On: Oct 08

The views  that are created  are based upon the underlying list definition
in the site definition. I believe that most of these lists are hot spots
in the list definition. So, you should be able to immediately see (after
an iisreset) any change  you make to the built-in views.

Didn't find what you were looking for? Find more on SPView change columns programmatically Or get search suggestion and latest updates.