Hi Imar:
Here is the code for Viewfile.aspx:
Code:
namespace WebCertifyNow.Main
{
public partial class ViewFile : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString.Get("Id") != null)
{
Response.Clear();
Guid id = new Guid(Request.QueryString.Get("Id"));
if (id != Guid.Empty)
{
File myFile = FileStorageManager.GetFile(id);
Response.ContentType = myFile.ContentType;
if (myFile.ContainsFile)
{
Response.BinaryWrite(myFile.FileData);
}
else
{
Response.Redirect(System.IO.Path.Combine(FileStorageManager.UploadsFolder, myFile.FileUrl));
}
}
else
Response.Redirect("~/Main/SubmittedQuestionnaire.aspx");
}
else
{
Response.Redirect("~/Main/SubmittedQuestionnaire.aspx");
}
}
}
}
[B]
Below is the code for calling Viewfile from another aspx page:[/B]
Code:
<asp:GridView ID="GridView1" runat="server" DataSourceID="AnswerDataSource" AutoGenerateColumns="False"
Width="687px" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px"
CellPadding="4" ForeColor="Black" RowHeaderColumn="CertificationName" CellSpacing="2"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="QuestionText" HeaderText="QuestionText" SortExpression="QuestionText" />
<asp:BoundField DataField="DetailText" HeaderText="DetailText" SortExpression="DetailText" />
<asp:CheckBoxField DataField="YesNoBoolValue" HeaderText="YesNoBoolValue" SortExpression="YesNoBoolValue" />
<asp:BoundField DataField="DocumentName" HeaderText="AttachedDocument" SortExpression="DocumentName" />
<asp:HyperLinkField DataTextField="DocumentName" HeaderText="DocumentName" SortExpression="DocumentName"
DataNavigateUrlFields="AttachedDocumentId" DataNavigateUrlFormatString="ViewFile.aspx?Id={0}"
NavigateUrl="~/Main" />
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#808080" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>