Dear Friends , here I am having problem with visual web part.After deploying into SharePoint it is not accessible for all users.It is accessible for only who created.When I try to log in with another user this webpart is not working .I used RunWithElevatedPrivileges method also,even though it is not working.Please help me to fix this issue.
here is is my code please check it and sort out my issue
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using System.Data;
using Microsoft.SharePoint.Utilities;
namespace BursaryVisualWebpart.BursaryCaseID_DocumentsVisualWebpart
{
public partial class BursaryCaseID_DocumentsVisualWebpartUserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
{
string bursaryapp = "BURSARY/2012/003";
SPList document = web.Lists["Requirement"];
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name='ReferenceNumber'/><Value Type='Text'>" + bursaryapp + "</Value></Eq></Where>";
SPListItemCollection objItemcoll = document.GetItems(query);
DataTable itemsDataTable = objItemcoll.GetDataTable();
GridView1.DataSource = itemsDataTable;
GridView1.DataBind();
}
}
});
}
}}