Solved assign data to a chart

Posted on 2011-10-23
Last Modified: 2012-08-14

I use the code below to populate GridView in 4
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.Label_Error1.Text = "Unable to connect to the database. " & Err.Description

        End If

        ' End If
    End Sub

Open in new window

Question by:murbro
    LVL 39

    Accepted Solution

    LVL 7

    Assisted Solution

    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.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";


    Author Closing Comment

    thanks for the help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now