Hi All,

 

I have been trying to figure out how to get the current view of a list
in the updating event handler but no luck. My problem is that I want to
know if the view is Standard or Grid and do different things depending
on the view. Something like this:

 

        /// <summary>

        /// Synchronous before event that occurs when an existing item
is changed, for example, when the user changes data in one or more
fields.

        /// </summary>

        /// <param name="properties">

        /// A Microsoft.SharePoint.SPItemEventProperties object that
represents properties of the event handler.

        /// </param>

        public override void ItemUpdating(SPItemEventProperties
properties)

        {

            if
(string.IsNullOrEmpty((string)properties.AfterProperties["Person"]) ==
true)

            {

                if
(string.IsNullOrEmpty((string)properties.AfterProperties["Return Date"])
== true)

                {

 
if(GetCurrentViewType(properties.ListItem.ParentList).CompareTo("GRID")
== 0)

                    {

                        properties.AfterProperties["Book out"] = 0;

                    }

                    else

                    {

                        properties.AfterProperties["Book out"] = false;

                    }

                }

            }

        }

 

        public string GetCurrentViewType(SPList List)

        {

            foreach (SPView View in List.Views)

            {

                // This does not work when the List is embedded in a
webPart

                if (View.Url.CompareTo(List.ParentWebUrl) == 0)

                {

                    return View.Type;

                }

            }

 

            return "N/A";

        }

 

I have tried to use the parameters.ItemList.ParentList object with the
GetView, Views and DefaultView properties but any of them return the
view used in the current context. Any help will be appreciated.

 

Regards,

 

Javier



This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.




------------------------------------------------------------------- OzMOSS.com 
- to unsubscribe from this list, send a message back to the list with 
'unsubscribe' as the subject.

Powered by mailenable.com

Reply via email to