chart in grid

2 posts, 0 answers
  1. Jelena Nahaja
    Jelena Nahaja avatar
    6 posts
    Member since:
    Apr 2010

    Posted 03 Mar 2011 Link to this post

    I  have "CHART_COLUMN" in grid and need to able to export grid  to .pdf as image.Problem is a chart.
     I saved chart as .jpeg. Could you check my code. I appreciate any help or resources.

        RadChart chart = (RadChart)item["CHART_COLUMN"].FindControl("RadChart1");
                    SetChart(chart, item);
                    MemoryStream imageStream = new MemoryStream();
                    chart.Save(imageStream, ImageFormat.Jpeg);
                    Byte[] imageContent = new Byte[imageStream.Length];
                    imageStream.Position = 0;
                    Response.ContentType = "image/gif";
                    imageStream.Read(imageContent, 0, (Int32)imageStream.Length);
                    imageStream.Close();


                    RadBinaryImage rbi = (RadBinaryImage)item["chartimage"].FindControl("RadBinaryImage1");
                    if (rbi != null)
                    {
                        rbi.DataValue = (Byte[])imageContent;
                       // rbi.DataBind();


                    }

  2. Jelena Nahaja
    Jelena Nahaja avatar
    6 posts
    Member since:
    Apr 2010

    Posted 04 Mar 2011 Link to this post

    I was able to resolve it
      protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = e.Item as GridDataItem;
    .........................some code here....................................
     RadChart chart = (RadChart)item["CHART_COLUMN"].FindControl("RadChart1");
                    SetChart(chart, item);
                    MemoryStream imageStream = new MemoryStream();
                    chart.Save(imageStream, ImageFormat.Jpeg);
                    Byte[] imageContent = new Byte[imageStream.Length];
                    imageStream.Position = 0;
                    imageStream.Read(imageContent, 0, (Int32)imageStream.Length);
                    RadBinaryImage rbi = (RadBinaryImage)item["chartimage"].FindControl("RadBinaryImage1");
                    if (rbi != null)
                    {
                        rbi.DataValue = imageContent;
                        rbi.DataBind();

                    }
    }
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top