ASP.net assign data to a chart

Hi

I use the code below to populate GridView in ASP.net 4 VB.net.
I need to populate a chart with the same data. What code would I use to do this?
Protected Sub Button_View_Results_Click(sender As Object, e As EventArgs) Handles Button_View_Results.Click

        If Me.Label_Reviewer.Text = "" Then
            Me.Label_Please_LogIn.Text = "Please log in first!"
            Exit Sub
        End If
        Me.Label_Please_LogIn.Text = ""

        'If Not IsPostBack Then

        Dim sSQL As String
        sSQL = "SELECT Answers.Survey, Answers.Category, Avg(Answers.Score) * 20 AS [Result Percentage] "
        sSQL = sSQL & "FROM Answers "
        sSQL = sSQL & "GROUP BY Answers.Survey, Answers.Category, Answers.ReviewerID "
        sSQL = sSQL & "HAVING (((Answers.ReviewerID)='" & Me.Label_Reviewer.Text & "'))"
        'sSQL = sSQL & "HAVING (((Answers.ReviewerID)='R'))"

        Dim queryString2 As String = sSQL


        ' Run the query and bind the resulting DataSet
        ' to the GridView control.
        Dim ds2 As DataSet = GetData(queryString2) 'test connection
        If (ds2.Tables.Count > 0) Then

            Me.GridView1.DataSource = ds2
            Me.GridView1.DataBind()

        Else

            'Me.Label_Error1.Text = "Unable to connect to the database. " & Err.Description

        End If
  

        ' End If
    End Sub

Open in new window

Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rahul GadeSr. ArchitectCommented:
A Quick sample using X and Y source, your query has 3 sources, so you will need to identify 2 of them for chart.

DataTable dt = new DataTable();
 dt.Columns.Add("Subject");
 dt.Columns.Add("Marks");
 
 dt.Rows.Add("Physics", 95);
 dt.Rows.Add("Maths", 82);
 dt.Rows.Add("English", 88);
 
 Chart1.DataSource = dt;
 Chart1.Series["Series1"].XValueMember = "Subject";
 Chart1.Series["Series1"].YValueMembers = "Marks";
 Chart1.DataBind();

-Rahul
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
thanks for the help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.