I can't help you with the server-side code, but if you open the page in a browser, view the source, and paste it here, I can help you debug the javascript that your server-side code renders.
On Thursday, July 4, 2013 10:02:02 AM UTC-4, Missy wrote: > > Hello. > I am trying to bind google charts with my database sql server using > asp.net c# but currently I am experiencing blank webpage, and I can not > figure out why? > > I am new into using google API, so please forgive and excuse my knowledge > and illiterate questions. > > *Asp.net:* > <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" > AutoEventWireup="true" > CodeFile="Default.aspx.cs" Inherits="_Default" %> > > <asp:Content ID="HeaderContent" runat="server" > ContentPlaceHolderID="HeadContent"> > > </asp:Content> > <asp:Content ID="BodyContent" runat="server" > ContentPlaceHolderID="MainContent"> > <script type="text/javascript" src="https://www.google.com/jsapi > "></script> > <script type="text/javascript"> > google.load('visualization', '1', { packages: ['corechart'] }); > </script> > <h2> > Testing G.Charts > </h2> > > <div id="chart_div" style="width: 900px; height: 500px;"></div> > <div runat="server" id="chart"/> > <div><asp:Label ID="msgLabel" runat="server"></asp:Label></div> > </asp:Content> > > CS.code: > using System; > using System.Collections.Generic; > using System.Linq; > using System.Collections; > using System.Configuration; > using System.Data; > using System.Web; > using System.Web.Security; > using System.Web.UI; > using System.Web.UI.HtmlControls; > using System.Web.UI.WebControls; > using System.Web.UI.WebControls.WebParts; > using System.Xml.Linq; > using System.Text; > using System.Data.SqlClient; > > > public partial class _Default : System.Web.UI.Page > { > > SqlConnection conn = new SqlConnection(); > StringBuilder str = new StringBuilder(); > > protected void Page_Load(object sender, EventArgs e) > { > > conn.ConnectionString = > ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; > conn.Open(); > > Load_Chart(); > } > > private void Load_Chart() > { > //select all from your table > SqlDataAdapter adp = new SqlDataAdapter("select top 100 > [ID],[Decimal price] from [dbo].[database_BWICs]", conn); > > DataTable dt = new DataTable(); > try > { > adp.Fill(dt); > str.Append(@"<script type=text/javascript> google.load( > *visualization*, *1*, {packages:[*corechart*]}); > google.setOnLoadCallback(drawChart); > function drawChart() { > var data = new google.visualization.DataTable(); > > data.addColumn('number', 'ID'); > data.addColumn('number', 'Decimal price'); > > data.addRows(" + dt.Rows.Count + ");"); > > Int32 i; > //looping through all the rows in the table > for (i = 0; i <= dt.Rows.Count - 1; i++) > { > > //str.Append("data.setValue( " + i + "," + 0 + "," + "'" + > dt.Rows[i]["Name"].ToString() + "');"); > > str.Append("data.setValue(" + i + "," + 0 + "," + > dt.Rows[i]["ID"].ToString() + ") ;"); > > str.Append(" data.setValue(" + i + "," + 1 + "," + > dt.Rows[i]["Decimal price"].ToString() + ");"); > } > //selected drop down list value to display specific chart > > > str.Append("var options = backgroundColor:'red'"); > str.Append(" chart.draw(data, options,{title: 'Company Performance',"); > str.Append(" var chart = new > google.visualization.BarChart(document.getElementById('chart_div'));"); > str.Append("vAxis: {title: 'Year', titleTextStyle: {color: > 'green'}}"); > str.Append("}); }"); > str.Append("</script>"); > > //lt.Text = str.ToString().TrimEnd(',').Replace('*', '"'); > chart.InnerHtml = str.ToString(); > > conn.Close(); > > } > catch (Exception ex) > { > msgLabel.Text = ex.Message; > } > finally > { > conn.Close(); > } > } > } > > *Any help would be very much appreciated. Thank you for your time and > solution. * > > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-visualization-api. For more options, visit https://groups.google.com/groups/opt_out.
