Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.
SPView AllItems = spList.Views["myview"] ;
AllItems.Formats = "<Format Name=\"Modified\"><FormatDef Type=\"ColWidth\" Value=\"534\" /></Format>";      
AllItems.Update();

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

2 Answers 2

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;
list.Update();
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

 
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.