try
{
SPWeb currentWeb = SPControl.GetContextWeb(Context);
SPList lstDoc = currentWeb.Lists["Shared Documents"];
SPQuery sQuery = new SPQuery();
sQuery.Query = "<OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy>";
sQuery.ViewAttributes = "<ViewAttributes Scope='Recursive' />";
SPListItemCollection myColl = lstDoc.GetItems(sQuery);
writer.Write("<Table>");
writer.Write("<Tr>");
writer.Write("<Td>");
writer.Write("<Strong>");
writer.Write("Document Name");
writer.Write("</Strong>");
writer.Write("</Td>");
writer.Write("</Tr>");
foreach (SPListItem item in myColl)
{
string strDocUrl = item["FileRef"].ToString();
strDocUrl = strDocUrl.Substring(strDocUrl.IndexOf('#') + 1);
string strOriginalUrl = currentWeb.Url + "/" + strDocUrl;
string strFileName = item["LinkFilename"].ToString();
writer.Write("<Tr>");
writer.Write("<Td>");
writer.Write("<A href='"+strOriginalUrl+"'>"+strFileName+"</A>");
writer.Write("</Td>");
writer.Write("</Tr>");
}
writer.Write("</Table>");
}
catch (Exception ex)
{
writer.Write(ex.ToString());
}
{
SPWeb currentWeb = SPControl.GetContextWeb(Context);
SPList lstDoc = currentWeb.Lists["Shared Documents"];
SPQuery sQuery = new SPQuery();
sQuery.Query = "<OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy>";
sQuery.ViewAttributes = "<ViewAttributes Scope='Recursive' />";
SPListItemCollection myColl = lstDoc.GetItems(sQuery);
writer.Write("<Table>");
writer.Write("<Tr>");
writer.Write("<Td>");
writer.Write("<Strong>");
writer.Write("Document Name");
writer.Write("</Strong>");
writer.Write("</Td>");
writer.Write("</Tr>");
foreach (SPListItem item in myColl)
{
string strDocUrl = item["FileRef"].ToString();
strDocUrl = strDocUrl.Substring(strDocUrl.IndexOf('#') + 1);
string strOriginalUrl = currentWeb.Url + "/" + strDocUrl;
string strFileName = item["LinkFilename"].ToString();
writer.Write("<Tr>");
writer.Write("<Td>");
writer.Write("<A href='"+strOriginalUrl+"'>"+strFileName+"</A>");
writer.Write("</Td>");
writer.Write("</Tr>");
}
writer.Write("</Table>");
}
catch (Exception ex)
{
writer.Write(ex.ToString());
}
No comments:
Post a Comment