Showing posts with label SharePoint 2010. Show all posts
Showing posts with label SharePoint 2010. Show all posts

Wednesday, July 10, 2013

Query Update list item

                   
It's took me 3 hours to update a value in list item . 3 hours to query update a list item in Sharepoint.

What I was trying simple

 items[0]["InternalListItemColumnNameToUpate"] = "True";

but this does not work....

To query update a list item in Sharepoint...use below

   SPListItem spListItem = items[0];
                            spListItem["InternalListItemColumnNameToUpate"] = "True";
                            web.AllowUnsafeUpdates = true;                          
                            spListItem.Update();
                            web.AllowUnsafeUpdates = false;


sample code...

  list = web.Lists.TryGetList("ListName");

                        SPQuery query = new SPQuery();

                        query.Query =
                        @"
                         
                             
                             " + SearchValue + "
";
                        SPListItemCollection items = list.GetItems(query);
                 
                            SPListItem spListItem = items[0];
                            spListItem["InternalListItemColumnNameToUpate"] = "True";
                            web.AllowUnsafeUpdates = true;                          
                            spListItem.Update();
                            web.AllowUnsafeUpdates = false;
                   

Wednesday, July 3, 2013

Deploy file using module

Lots of time there is need to deploy files...example you wants to deploy JS file to Style Library in Sharepoint. Add a module item to you project and JS file to module

Simple click on Elements.xls file and put entries like below

URL element in Module tag is the library where one wants to place files. Path tag in File element is the path of file in project and URL is in style library in my case.

Friday, June 28, 2013

error occurred in deployment step 'Activate Features': Cannot complete this action

error occurred in deployment step 'Activate Features': Cannot complete this action

error message while creation of custom list defination to fix this make sure that you have included FeatureId of feather deploying your list defination at ListInstance.

Thursday, June 27, 2013

Relative Paths using Style Library

Relative Paths using Style Library


                                      



               
                                               
                                                ImageUrl="<% $SPUrl:~sitecollection/Style Library/Images/btnMinus.jpg %>">