try
{
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite oSite = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb oWeb = oSite.OpenWeb())
{ #region PriorityDropdown
SPList ospList = oWeb.Lists.TryGetList("ListName");
if (ospList != null)
{
SPListItemCollection osplistcollection = ospList.GetItems();
DataTable dtInvoice = new DataTable();
dtInvoice = osplistcollection.GetDataTable();
ddlPriorityAllocation.DataSource = dtInvoice;
ddlPriorityAllocation.DataValueField = Convert.ToString(dtInvoice.Columns["Title"]);
ddlPriorityAllocation.DataTextField = Convert.ToString(dtInvoice.Columns["Title"]);
ddlPriorityAllocation.DataBind();
ddlPriorityAllocation.Items.Insert(0, "--Select--");
ddlPriorityAllocation.SelectedIndex = ddlPriorityAllocation.Items.IndexOf(ddlPriorityAllocation.Items.FindByText("--Select--"));
}
#endregion
}
}
});
}
catch
{ }
No comments:
Post a Comment