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>


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) {
var title = result.Title;
var emp=result.Employee;
var empid=result.EMPID;




//dont need headers again here



count = count +1;




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’ ”


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))






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



Originally posted on 9to5Mac:

Steve Jobs Fearless GeniusBecoming Steve Jobs, the new biography of Steve Jobs by Brent Schlender and Rick Tetzeli, will be officially released tomorrow by Crown Business/Penguin Random House, and is currently available as a pre-order from Amazon ($12+) and Apple’s iBookstore ($13). Here are just some of the interesting revelations found inside, including some details regarding Jobs’ evolving attitude towards the media.

Jobs’ return to Apple was almost certainly not a strategic takeover. Despite speculation that Steve Jobs may have strategically orchestrated a takeover of Apple during his sale of NeXT — a view shared by Bill Gates and former Apple CEO Gil Amelio — the book suggests that Jobs was truly uncertain about his continued involvement with the company. Avie Tevanian and Jon Rubinstein, “the two men whom Steve trusted the most at Apple… agree that Steve did not intend to become Apple’s CEO,” and that they didn’t think they…

View original 643 more words

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


DataView dvt=new Dataview(dt);

dvt.sort=”RollNno ASC”;

//then again assign that view to datatable dt.



service bus unable to uninstall issue problem in sharepoint 2013 Workflow related

Leave a comment

Sometimes, you need to uninstall Windows Service Bus 1.0 and it will not disconnect “Leave the Farm”

Follow steps:

1) Open Run and Type regedit

Delete the \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Service Bus folder

Then go and do uninstallation it will be perfect

Older Entries


Get every new post delivered to your Inbox.

Join 283 other followers

%d bloggers like this: