Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

how to get first index in ListItemCollectionPosition

$
0
0

Hi Every One

   I have one issue in SPList.ListItemCollectionPosition. it is return second page start index( query). I need to get first page index(query). I am using following code.

int totalItemCount = SPWeb.Lists.TryGetList("ListName").ItemCount;
                                radListView.VirtualItemCount = totalItemCount;

                                int startindex = radListView.CurrentPageIndex;
                                int t = ((RadDataPager)radListView.FindControl(RAD_PAGER_ID)).PageSize;


                                List<string> qu = new List<string>();

                                SPQuery query = new SPQuery();

                                query.RowLimit = Convert.ToUInt32(t);

                                string pagingData = string.Empty;
                                SPListItemCollectionPosition poss = null;
                                while (true)
                                {
                                    query.ListItemCollectionPosition = poss;
                                    SPList sp1List = SPWeb.Lists.TryGetList("ListName");
                                    SPListItemCollection lic = SPWeb.Lists.TryGetList("ListName").GetItems(query);
                                    poss = lic.ListItemCollectionPosition;

                                    if (poss != null)
                                        qu.Add(poss.PagingInfo.ToString());
                                    else if (poss == null)
                                        break;
                                }

                                quCount = qu.Count;
                                startindex = qu.Count <= startindex ? 0 : startindex;
                                SPListItemCollectionPosition pos = new SPListItemCollectionPosition(qu[startindex]);
 

thanks

navaratan

 


Navaratan Sharma


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>