Sign in to follow this  
tosaito

Chart with strXML generated from GridView

Recommended Posts

Hi. I created a MSLine chart with strXML generated from the data displayed on GridView and it works fine.

I want to update the chart when GridView is sorted but it didn't work at all.

Can anybody tell me how to run createchart() whenerver I want to pull the triger like sorted or cliked?

I tried this but this didn't work.

    Protected Sub GridView1_Sorted(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.Sorted
createchart()
    End Sub

Share this post


Link to post
Share on other sites

Hi Toshiyuki Saito,

  Please build the XML again in the "sorted" event and re-render the chart. You can call createchart() [where this XML building and re-rendering of chart occurs] from GridView1_Sorted event. In createchart() please read data from grid view control object rather than the datasource. Please see the code below for createChart() which  you might use and modify in our application.

----------------------------------------------------------------------

Protected

Sub GridView1_Sorted(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.Sorted

CreateChart()

End Sub

-------------------------------------------------------------------------

Public

Sub CreateChart()

Dim strXML As New StringBuilder()

strXML.Append(

"<chart>")

Dim i As Integer

For i = 0 To GridView1.Rows.Count - 1

strXML.Append(

"<set value='" & GridView1.Rows(i).Cells(1).Text & "' label='" & GridView1.Rows(i).Cells(0).Text & "' />")

Next

strXML.Append(

"</chart>")

Literal1.Text = FusionCharts.RenderChart(

"FusionCharts/Column2D.swf", "", strXML.ToString(), "ChartID", "350", "300", False, False)

End Sub

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this