are you storing it in a database? if yes, how is it stored in the database?
you probably need to show more relevant parts of your code.
g.
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
Matevz
Member
2 Points
42 Posts
rendering apostrophe
Feb 24, 2013 08:35 PM|LINK
Hi,
when using this code :
rowsList.Add("['Datum', 'Sava', 'RPWS1']");It get rendered like :
['Datum', 'Sava', 'RPWS1']
How can i change the code so it would render like it should?
gerrylowry
All-Star
20513 Points
5712 Posts
Re: rendering apostrophe
Feb 24, 2013 08:45 PM|LINK
@ Matevz welcome to forums.asp.net
rendered where? ASP.NET MVC? Web Forms? other?
are you storing it in a database? if yes, how is it stored in the database?
you probably need to show more relevant parts of your code.
g.
Matevz
Member
2 Points
42 Posts
Re: rendering apostrophe
Feb 24, 2013 09:04 PM|LINK
Hi, thanks for reply.
Here is the code :
@using System.Data; @using System.Collections.Generic; @using System.Data.SqlClient; @{ Layout = null; string connectionString="Server=xxx.xxx.xxx.xxx\\sqlexpress; Database=HEK; Uid=xxxxxxx; Pwd=xxxxxxxxx"; DataTable dt = new DataTable(); String rows = ""; using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); using (SqlDataAdapter adapter = new SqlDataAdapter("SELECT Datum, Sava, RPWS1 FROM vws", conn)) { adapter.Fill(dt); List<string> rowsList = new List<string>(); rowsList.Add("['Datum', 'Sava', 'RPWS1']"); foreach (DataRow row in dt.Rows) { //Converts your object into a DateTime (so that it's properties can be accessed properly DateTime yourDate = Convert.ToDateTime(row["Datum"]); rowsList.Add("[new Date(" + yourDate.Year + ", " + (yourDate.Month - 1) + ", " + yourDate.Day + ", " + yourDate.Hour + ", " + yourDate.Minute + ", " + yourDate.Second + "), " + row["Sava"] + ", " + row["RPWS1"] + "]"); } rows = String.Join(", ", rowsList); }; }; } <script type='text/javascript' src="http://www.google.com/jsapi"></script> <script type="text/javascript"> function drawChart() { var data1 = google.visualization.DataTable() data1.addColumn('datetime', 'Datum'); data1.addColumn('number', 'Savum'); data1.addColumm('number', 'RPWS1'); data1.addRows([@rows]); var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data1, { height: 350, width: 900, title: 'Absolutna kota vode v tesnilni zavesi', vAxis: { maxValue: 165.5, minValue: 159, title: 'absolutna kota' } }); } </script>