Gird view  auto refreshing

Hi,

I am binding my list items unto the grid which displays all the items but my gird should display only the latest 5 items in the Gird whenever the list is updated, Please do Help me out !!

Thanks and Regards,

Santo,

May 28th, 2015 2:15am

Hi

You can use caml query to get the data by sorting on created 

SPQuery query = new SPQuery(); query.Query = "<OrderBy><FieldRef Name='created' Ascending='FALSE' /></OrderBy>";

or you can sort by ID so it will have latest records.

<OrderBy>
    <FieldRef Name='ID' Ascending='FALSE'/>
</OrderBy>

and set the query limit to 5 as to get top 5 records

query.RowLimit=5

and regarding refresh if you want,then you have to handle via ajax update panel and Timer control which will call after certain interval.

Free Windows Admin Tool Kit Click here and download it now
May 28th, 2015 2:20am

Hi,

Thanks for You'r fast reply!!!

I don't have much knowledge of ajax update panel could you please help me out with some other solution !!!

thanks,

Santto

May 28th, 2015 2:30am

Hi

You want auto refresh functionality on page or on web part,and if i am correct you want to refresh grid automatically or user will refresh the page.

or can you explain more.

Free Windows Admin Tool Kit Click here and download it now
May 28th, 2015 2:35am

Hi,

it should refresh automatically in webpart .

thanks,

Santto

May 28th, 2015 2:42am

Hi

see if this help

http://www.c-sharpcorner.com/UploadFile/720a73/autorefresh-sharepoint-list-using-javascript3/

http://manish-sharepoint.blogspot.in/2012/01/refreshing-webparts-automatically-on.html

and you can also achieve the same using OOTB ,create list view webpart and set your row limit and order by modifiying view and enable ajax option

http://www.c-sharpcorner.com/uploadfile/Roji.Joy/how-to-enable-ajax-options-in-list-view-web-parts-sharepoint-2010/

Free Windows Admin Tool Kit Click here and download it now
May 28th, 2015 2:44am

Hi,

You can use sharepoint CEWP. In the HTML Source box, enter the following javascript code:

function refreshpage()

{

window.location = window.location

}

setTimeout(refreshPage, 3000000)

May 28th, 2015 3:45am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics