images upload with Ajax

Posted by Jayakumars under ASP.NET on 4/26/2011 | Points: 10 | Views : 1296 | Status : [Member] [MVP] | Replies : 1
hi

How to Bind images to datagrid then view new iframe and download events
how it is possible i am try this method any one change this method

below my code

<ItemTemplate>
<asp:LinkButton ID="lnkDownload" runat ="server" Text ='<%# Eval("Download") %>' OnClientClick =popup('<%# Eval("Empid") %>');"></asp:LinkButton>
</ItemTemplate>

how to download them using datagrid and datagridviews

Mark as Answer if its helpful to you


Responses

Posted by: Tijut2k on: 4/26/2011 [Member] Starter | Points: 25

Up
0
Down
This may help for u

aspx code
<asp:TemplateField HeaderText="Name of File" SortExpression="CatFileUpdName" ItemStyle-ForeColor="#386a93">
<ItemTemplate>
<asp:LinkButton ID="lnkFileName" runat="server" CausesValidation="false" CommandArgument='<%# Eval("FilePath")%>'
CommandName="Download" Text='<%#Eval("UploadName")%>' ForeColor="#386a93"></asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>

C# Code

protected void grdview_RowCommand(object sender, GridViewCommandEventArgs e)
{

// For Download File From Grid
if (e.CommandName == "Download")
{
string filename = e.CommandArgument.ToString();

if (fileName != "")
{
System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath(fileName));
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
else
{
// "This file does not exist.";
}
}
}

}

Best Regard's
Tiju Thankachan

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response