Adding Paging in SPGridview

Hi Guys,

Many times we need to create custom SpGridview control and need to add paging in such control,Here I have gone through bit of code which facilitate to add paging in SPGridview Control.

SPGridView gv = new SPGridView();
gv.AutoGenerateColumns = false;
gv.AllowPaging = true;
gv.PageSize = 10;
gv.PageIndexChanging += new GridViewPageEventHandler(gv_PageIndexChanging);

gv.PagerTemplate = null; //You must add this line before binding the DataSource.
gv.DataSource = dv;//Here dv is an object of Dataview
gv.DataBind();

Now you need to add PageIndexChanging Event.

void gv_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gv.PageIndex = e.NewPageIndex;
gv.DataBind();
}

Hope it will help you.

Error : Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Hello All

I have created list in my SharePoint Site. And my requirement is to get data from SharePoint Site.

Here is my Simple code:

using (SPSite site = new SPSite(siteurl))
{
using (SPWeb web = site.OpenWeb())
{
SPList lstUsers = web.Lists["SiteUsers"];
SPQuery Qry = new SPQuery();
Qry.Query = "<Where><Eq><FieldRef Name='IsActive' /><Value Type='Boolean'>0</Value></Eq></Where>";
DataTable dtUsers = lstUsers.GetItems(Qry).GetDataTable();
if (dtUsers != null && dtUsers.Rows.Count > 0)
{
//Bind the data
}
}
}
}


When I am trying to get data from the SharePoint List, I got this Error Message:

Error : ‘Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack’

After doing some research I found solution. I need to change the Authentication mode in configuration file from ‘Form’ to ‘Windows’.

Solution : <authentication mode="Forms"> replace with <authentication mode="Windows">

That’s it, Problem Solved.
It works fine for me, Hope it helps

Forms Authentication in SharePoint

Hello All,


Here is the good article which explain how to extend FBA site from Window Authenticate site and How to configure Forms Authentication in SharePoint Site.

This article provides detailed description of how to configure Forms Authentication with SharePoint site with code.

Thanks.