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.

2 Answers 2

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);
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();
1
  • That did not work. The view displays as standard view instead of intended datasheet view.
    – lu A
    Commented Jun 14, 2011 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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