try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
StringBuilder strMovieListings = new StringBuilder();
strMovieListings.Append("<Table width='100%' cellpadding='0' cellspacing='0'>");
strMovieListings.Append("<Tr>");
strMovieListings.Append("<Td bgcolor='#add8e6'>");
strMovieListings.Append("<Strong>");
strMovieListings.Append("Movie Name");
strMovieListings.Append("</Strong>");
strMovieListings.Append("</Td>");
strMovieListings.Append("</Tr>");
SPWeb currentWeb = SPContext.Current.Web;
SPList lstMovieListings = currentWeb.Lists["Movie Listings"];
SPListItemCollection myColl = lstMovieListings.Items;
if (myColl.Count > 0)
{
foreach (SPListItem item in myColl)
{
string strTitle = string.Empty;
strTitle = item.Title.ToString();
strMovieListings.Append("<Tr>");
strMovieListings.Append("<Td>");
strMovieListings.Append(strTitle);
strMovieListings.Append("</Td>");
strMovieListings.Append("</Tr>");
}
}
strMovieListings.Append("</Table>");
writer.Write(strMovieListings);
});
}
catch (Exception ex)
{
writer.Write(ex.ToString());
}
}
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
StringBuilder strMovieListings = new StringBuilder();
strMovieListings.Append("<Table width='100%' cellpadding='0' cellspacing='0'>");
strMovieListings.Append("<Tr>");
strMovieListings.Append("<Td bgcolor='#add8e6'>");
strMovieListings.Append("<Strong>");
strMovieListings.Append("Movie Name");
strMovieListings.Append("</Strong>");
strMovieListings.Append("</Td>");
strMovieListings.Append("</Tr>");
SPWeb currentWeb = SPContext.Current.Web;
SPList lstMovieListings = currentWeb.Lists["Movie Listings"];
SPListItemCollection myColl = lstMovieListings.Items;
if (myColl.Count > 0)
{
foreach (SPListItem item in myColl)
{
string strTitle = string.Empty;
strTitle = item.Title.ToString();
strMovieListings.Append("<Tr>");
strMovieListings.Append("<Td>");
strMovieListings.Append(strTitle);
strMovieListings.Append("</Td>");
strMovieListings.Append("</Tr>");
}
}
strMovieListings.Append("</Table>");
writer.Write(strMovieListings);
});
}
catch (Exception ex)
{
writer.Write(ex.ToString());
}
}
No comments:
Post a Comment