Unable to Download image in radgrid as radgird added in radajaxmanager

1 posts, 0 answers
  1. Manish
    Manish avatar
    64 posts
    Member since:
    Jul 2011

    Posted 02 May 2014 Link to this post

    I have used following ajax manager in my page and i have used user control Schedule_Review_Narrative1 on this page to which i have tool into ajax manager 
    and i have my grid in Schedule_Review_Narrative1 and in that grid i have applied code to download image but not able to download image.

    Problem : i want to use ajax in grid as well as i need to run code to download document. 

    <telerik:RadAjaxManager ID="RAMMileston" runat="server">
                <telerik:AjaxSetting AjaxControlID="Schedule_Review_Left_Navigation1">
                        <telerik:AjaxUpdatedControl ControlID="Schedule_Review_Narrative1" />
                        <telerik:AjaxUpdatedControl ControlID="Schedule_Review_Left_Navigation1" />

    in link button i have gave command name  to link button and in rggrid_ItemCommand () i have gave following code but not able to download so please help me in this 

        else if (e.CommandName == "DownloadFile")
                                SqlConnection objSqlCon = new SqlConnection(db.ConnectionString);
                                SqlTransaction objSqlTran = objSqlCon.BeginTransaction();

                                SqlCommand objSqlCmd = new SqlCommand("Procedure_Name", objSqlCon, objSqlTran);
                                objSqlCmd.CommandType = CommandType.StoredProcedure;

                                SqlParameter objSqlParam1 = new SqlParameter("@FileGUID", SqlDbType.VarChar);
                                objSqlParam1.Value = e.CommandArgument;

                                string path = string.Empty;
                                string FileType = string.Empty;
                                string FormName = string.Empty;

                                using (SqlDataReader sdr = objSqlCmd.ExecuteReader())
                                    while (sdr.Read())
                                        path = sdr[0].ToString();
                                        FileType = sdr[1].ToString();
                                        FormName = sdr[2].ToString();


                                objSqlCmd = new SqlCommand("SELECT GET_FILESTREAM_TRANSACTION_CONTEXT()", objSqlCon, objSqlTran);
                                byte[] objContext = (byte[])objSqlCmd.ExecuteScalar();
                                SqlFileStream objSqlFileStream = new SqlFileStream(path, objContext, FileAccess.Read);
                                byte[] buffer = new byte[(int)objSqlFileStream.Length];
                                objSqlFileStream.Read(buffer, 0, buffer.Length);

                                FormName = FormName.Replace(";", "").Replace(",", " ");
                                Response.AddHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(FormName) + FileType);
                                // Here you need to manage the download file stuff according to your need
                                Response.ContentType = "application/octet-stream";

    Please help me in this.
Back to Top