Tuesday, July 30, 2013

Ho to export data from Repeater to Excel file.

You need to add this in your code and i hope you will get your solution.

Response.Clear()
        Response.Buffer = True

        Response.AddHeader("content-disposition", "attachment;filename=Download History(" + Date.Now + ").xls")

        Response.Charset = ""
        Me.EnableViewState = False
        Response.ContentType = "application/vnd.ms-excel"
        Dim sw As New StringWriter()
        Dim hw As New HtmlTextWriter(sw)
'Add all data in Repeater.
        Repeater1.RenderControl(hw)
        Response.Output.Write(sw.ToString())
        Response.Flush()
        Response.[End]()

Thursday, July 25, 2013

REST in SharePoint 2010

This topic is start up of SharePoint REST.

To make querying easier, Microsoft implemented REST (Representational State Transfer plus HTTP) into the SharePoint 2010 platform using ADO.NET Data Services to make client-side data retrieval easier and more lightweight.

What is REST, you ask?
It is the Web itself as it was originally intention-ed, a client either in transition between application states or "at rest“, able to interact with its user, but creates no load and consumes no per-client storage.
It is also security-trimmed just like everything else in the SharePoint platform.

So what does that really mean?
It is simply SharePoint data, or any oData-compliant (Open Data Protocol) information, output to the client like an RSS feed.

Note: if you are not seeing the SharePoint List information as XML in the browser then you'll need to turn off RSS feed reading. In Internet Explorer 7 or greater, go to Tools-->Internet Options-->Content tab-->Feeds and Web Slices-settings.


So how do we access it?

For SharePoint 2010, we change our Site URL to access the always-on service.

http://myjobs:50000/yourSite/_vti_bin/ListData.svc

Now we'll target a specific List by copying the name of our target List from the page (to avoid typos) and appending it to our URL, telling the REST service to 'target' that list for output.

http://myjobs:50000/yourSite/_vti_bin/ListData.svc/ListName

The primary ones you will probably use are $orderby, $top, and $filter with some Logical Operators.

Let's first only pull the top 2 of the records back as that's what the business is looking for.
http://myjobs:50000/yourSite/_vti_bin/ListData.svc/EmployeeDirectory?$top=2

That's good, but we forgot to sort by anything to control which records are returned. We'll now add an order by clause to correct that.
http://myjobs:50000/yourSite/_vti_bin/ListData.svc/EmployeeDirectory?$top=2&$orderby=Modified desc.

Wednesday, July 24, 2013

Get Data of current login user in Sharpoint

Some time we need to get data according to current user.
Like items that has been created by current login user.

And there so many approach to do this but what i will recommend that never goes wrong.

  osb.Append("     <Where>")
  osb.Append("                       <Eq>")
   osb.Append("                            <FieldRef Name=""Author"" LookupId=""True"" />")
    osb.Append("                            <Value Type=""Lookup""   >" & SPContext.Current.Web.CurrentUser.ID & "</Value>")
    osb.Append("                        </Eq>")
    osb.Append("         </Where>")


Just add this query and get what you wanted :D