1
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.

3

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);
| improve this answer | |
2

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