SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
SPView AllItems = spList.Views["myview"] ;
AllItems.Formats = "<Format Name=\"Modified\"><FormatDef Type=\"ColWidth\" Value=\"534\" /></Format>";      

Why isn't this working? No error is given; the view is there. But the datasheet view does not automatically appears when I click on the list.

share|improve this question

I guess I dont need the format part. All I had to do make viewtype to grid. I dont even have to format each field (like I posted in the original email).

oViewCollection.Add(strViewName, viewFields, strQuery, 100, true, true, SPViewCollection.SPViewType.Grid,false);
share|improve this answer

You need to update the DefaultView property of the list.

// set web = the SPWeb that your list is in
SPList list = web.Lists["My List"];
list.Views["myview"].DefaultView = true;
share|improve this answer
That did not work. The view displays as standard view instead of intended datasheet view. – lu A Jun 14 '11 at 14:38

Your Answer


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.