if (e.CommandName == "View")
{
ImageButton lb = (ImageButton)e.CommandSource;
GridViewRow gvr = (GridViewRow)lb.NamingContainer;
string id = (string)gvdetails.DataKeys[gvr.RowIndex].Value;
Session["applciationid"] = id;
DataSet ds = obj.GetDisbursmentDetais(id);
Session["DocumentLocation"] = ds.Tables[0].Rows[0]["DocuemtnFile"].ToString();
string filename = Server.MapPath(Session["DocumentLocation"].ToString());
FileInfo fileInf = new FileInfo(filename);
if (fileInf.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "inline;attachment; filename=" + fileInf.Name);
Response.AddHeader("Content-Length", fileInf.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Flush();
Response.TransmitFile(fileInf.FullName);
}
else
{
Label1.Text="<script>"+Environment.NewLine+"alert('NO File is there')</script>";
}
}
{
ImageButton lb = (ImageButton)e.CommandSource;
GridViewRow gvr = (GridViewRow)lb.NamingContainer;
string id = (string)gvdetails.DataKeys[gvr.RowIndex].Value;
Session["applciationid"] = id;
DataSet ds = obj.GetDisbursmentDetais(id);
Session["DocumentLocation"] = ds.Tables[0].Rows[0]["DocuemtnFile"].ToString();
string filename = Server.MapPath(Session["DocumentLocation"].ToString());
FileInfo fileInf = new FileInfo(filename);
if (fileInf.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "inline;attachment; filename=" + fileInf.Name);
Response.AddHeader("Content-Length", fileInf.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Flush();
Response.TransmitFile(fileInf.FullName);
}
else
{
Label1.Text="<script>"+Environment.NewLine+"alert('NO File is there')</script>";
}
}
No comments:
Post a Comment