Updating A View Name With An Event Receiver
There was a question in the newsgroups regarding updating / altering a view name of a list through code when in an event handler. The solution is actually pretty simple, you can use the following code within the event handler in order to adjust the name of the view by passing in some simple parameters. The parameters that it takes are pretty straightforward, all it takes at the ID of the list that is going to be changed, the ID of the view that is going to be changed, along with the new name of the view that you want to apply. You have to get a reference of the list that you are wanting to adjust by passing in the ID of the list, and then get a reference to the view by passing view ID. Once you have that, you can adjust the Title property of the SPView object, then just update the view.
- public void UpdateViewName(Guid listID, Guid viewID, string newViewName)
- SPList oList = web.Lists[listID];
- SPView oView = oList.Views[viewID];
- oView.Title = newViewName;
Hope this helps someone.