This is a migrated thread and some comments may be shown as answers.

refresh RADgrid after download

4 Answers 239 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Neo
Top achievements
Rank 1
Neo asked on 01 Feb 2011, 09:35 PM
Hello All,

I have requirement to refresh the RADGrid after user download the selection. So i have first column as checkboxes and users selects those checkbox and as per the selection code gets the document and gives it for download to user.


                        Response.ContentType = "text/plain";
                        Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName);
                        Response.ClearContent();
                        Response.Buffer = true;
                        Response.Write(objBuilder.ToString());
                        Response.End();


So now i have to remove the selection after download and make those records of RADGrid with different color to indicate that record is already downloaded. how i can do that ?

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 07 Feb 2011, 02:09 PM
Hello,

Please try the following:

1) Add the desired code to the ItemDataBound event
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            CheckBox cb = e.Item.FindControl("CheckBox1") as CheckBox;
            cb.BackColor = System.Drawing.Color.Red;
        }
      }

2) Update your database to mark the current row as "exported"
3) Execute your code but replace Response.End with Response.Redirect so that the page can be refreshed afterwards

Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Neo
Top achievements
Rank 1
answered on 07 Feb 2011, 06:43 PM
Hello,

Item 1 & 2 works fine, but 3 one is not working as it suppose to.

If i apply Response.Redirect instead of Response.End it does not download the document it suppose to.

It just redirects user to the page but i also want  document to be downloaded with refresh.

Response.ContentType = "text/plain";
                        Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName + ".dat");
                        Response.ClearContent();
                        Response.Buffer = true;
                        Response.Write(objBuilder.ToString());
                        Response.Redirect("default.aspx",false);

Thanks.
0
Neo
Top achievements
Rank 1
answered on 09 Feb 2011, 05:12 PM
3) Execute your code but replace Response.End with Response.Redirect so that the page can be refreshed afterwards

The above one does not work in this case. if i write Response.Redirect after my code it does not download the file.
0
Daniel
Telerik team
answered on 10 Feb 2011, 10:40 PM
Hello,

Instead of writing the file to the response I suggest that you save it to the disk and then provide a direct download link as shown in the attached example.

Kind regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Neo
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Neo
Top achievements
Rank 1
Share this question
or