The backup file should be restored to a server with version ‘4.2.9.0’ or later.

Leave a comment


Go to Central Administration –> Application Management –> Manage content databases —> see the name of database.
Now go to Powershell and type this command
Upgrade-SPContentDatabase WSS_Content

In the place of WSS_Content write your content db name.Once its executes.You can restore backup

Using list service to display data in sharepoint site page

Leave a comment


Situation: Need to display a set of data in sharepoint list based on a dropdown in the page. For that if we plan to write a visualwebpart. But while changing the values in the dropdown Postbacks will occur which will be not smooth.

To handle this is in a simple way we can use 1) Ajax 2) List service.

Here I will explain with List service.

1) Create a Sharepoint list “EmployeeList”

2) The list service will be accessed as: http://abc:123/_vti_bin/ListData.svc/EmployeeList (This is an example)

3)Now we need to create a new page in Sitepages.

4) In that new page insert a Content Editor  Web Part (CEWP)

5) Now Open a Notepad and write your Jquery code and save it as Employee.JS and give a reference in the new page created.

Point to remember: You must place the js reference link only in between the PlaceHolderAdditionalPageHead. nOT ONLY .JS  we can refer .css files also in PlaceHolderAdditionalPageHead.

<asp:Content ContentPlaceHolderId=”PlaceHolderAdditionalPageHead” runat=”server”>

<script type=”text/javascript” src=”/SitePages/employee.js”></script>

</asp:Content

6) After referencing write a code in employee.js to retrieve all the list data and show them or render it in a tabular form

7) employee.js

$(document).ready(function() {

var url=” http://abc:123/_vti_bin/ListData.svc/EmployeeList ” ;

$.getJSON(url,function(data) {
var count = 0;
html= “<table>”;
$.each(data.d.results, function(i,result) {
if(result.Employee!=null)
{
var title = result.Title;
var emp=result.Employee;
var empid=result.EMPID;
if(count==0)
{
html+=”<tr><th><b>Employee</b></th><th><span><b>EMPID</b></th></tr><tr><td><b>”+emp+”</b></td><td><span><b>”+empid+”</b></td></tr>”;

html+=”</div>”;
}

else

{

//dont need headers again here

html+=”<tr><td><b>”+emp+”</b></td><td><span><b>”+empid+”</b></td></tr>”;

}

count = count +1;

}

});
html+=”</tr>”;
html+=”</table>”;
$(‘#Result’).append($(html));

});

8) now we need a content editor webpart to render our html output. here we given according to jquery with a div

<div id=”Result” style=”font-size: 10px; color: blue”></div>

9)take a text file and copy above html code and link that with content editor webpart

10) Then in browser it will render all table data

Suppose if you want filter data with some specific value you must give list service url as like this:

http://abc:123/_vti_bin/ListData.svc/EmployeeList?$filter=EMPID eq ‘1234’ ”

References:

https://msdn.microsoft.com/en-us/library/lists%28v=office.12%29.aspx

The type or namespace name ‘DataContract’ could not be found (are you missing a using directive or an assembly reference?

Leave a comment


just add:

add System.Runtime.Serialization in references

limit the iterations in foreach loop c#

Leave a comment


Hi All,

Sometimes there will be a huge data to loop through but you need to check for few iterations only say 10. In that case items collections in foreach loop contains a built in method to limit the iterations.TAKE

foreach (Object o in collection.Items.Take(10))

{

     ……

}

Ref: https://msdn.microsoft.com/en-us/library/ms132403(v=vs.110).aspx

Take<T>

Returns a specified number of contiguous elements from the start of a sequence. (Defined by Enumerable.)

Five fascinating revelations from ‘Becoming Steve Jobs’

Leave a comment


Read

Get current logged user in list event receivers?

Leave a comment


SPUser user = properties.Web.CurrentUser;

Sort Datatable values in Ascending Order

Leave a comment


NameSpace:  System.Data

We need to use DataView.Sort Property

Let us consider you already have a Datatable dt with some content in it and you want sort it in ascending order by the column Rollno

Then…

DataView dvt=new Dataview(dt);

dvt.sort=”RollNno ASC”;

//then again assign that view to datatable dt.

dt=dvt.ToTable();

Reference: https://msdn.microsoft.com/en-us/library/system.data.dataview.sort%28v=vs.110%29.aspx

Older Entries

Follow

Get every new post delivered to your Inbox.

Join 313 other followers

%d bloggers like this: