I suspect that the problem is a scope issue: "rows" is local to the inner 
"using" call, and so isn't available when you call it down in the 
javascript.  Declaring it outside the "using" call should fix the problem:

    @using System.Data;
    @using System.Collections.Generic;
    @using System.Data.SqlClient;
    @{    
        Layout = null;

        string connectionString="Server=xxx.xxx.xxx.xxx,1433\\sqlexpress; 
Database=HEK; Uid=sa; Pwd=xxxxxxxxxxxxx";
        DataTable dt = new DataTable();
String rows = new String();
        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)
                {
                    rowsList.Add("[" + row["Datum"] + ", " + 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.arrayToDataTable([@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'
}
});
}

google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawChart);
</script>
<div id="chart_div"></div>

On Friday, February 22, 2013 3:23:16 PM UTC-5, Matevz Uros Pavlic wrote:
>
> Hi, 
>
> here are they. Thanks for helping, 
> m
>
> 2013/2/22 asgallant <[email protected] <javascript:>>
>
>> Can you post the cshtml file and an example of the javascript rendered by 
>> the server (open the page in a browser and view the source)?
>>
>>
>> On Friday, February 22, 2013 1:33:14 PM UTC-5, Matevz Uros Pavlic wrote:
>>
>>> No, I saw the, i tried it before also...it doesn't work. Same error...
>>>
>>> The name 'rows' does not exist in the current context
>>>
>>>
>>> 2013/2/22 asgallant <[email protected]>
>>>
>>>> I made an error in my code above, it should be:
>>>>
>>>> var data = google.visualization.**arrayToDataTable([@rows]);
>>>>
>>>> On Friday, February 22, 2013 12:30:36 PM UTC-5, Matevz Uros Pavlic 
>>>> wrote:
>>>>>
>>>>> Hi, 
>>>>>
>>>>> c# part seems to work ok....but i get an error in HTML and Javascript, 
>>>>> still sayin rowsList :"The name 'rowsList' does not exist in the current 
>>>>> context." 
>>>>>
>>>>> If i check to see what rows c#, using Response.Write(rows); i get the 
>>>>> string in a form of* :*
>>>>> *
>>>>> *
>>>>> ['Datum', 'Sava', 'RPWS1'], [29.8.2012 18:00:00, 161.87, 161.79], 
>>>>> [29.8.2012 20:00:00, 161.86, 161.77], [........
>>>>>
>>>>> Which is correct,...
>>>>>
>>>>> But using @rowsList or @rows produces the above error. 
>>>>> Could there be a problem passing variable *rows* or *rowsList  *to 
>>>>> Java and HTML?
>>>>>
>>>>>   
>>>>>>>>>>>>>  -- 
>>>> 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 google-visualization-api+**[email protected].
>>>> To post to this group, send email to google-visua...@**googlegroups.com
>>>> .
>>>>
>>>> Visit this group at http://groups.google.com/**
>>>> group/google-visualization-**api?hl=en<http://groups.google.com/group/google-visualization-api?hl=en>
>>>> .
>>>> For more options, visit 
>>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>>> .
>>>>  
>>>>  
>>>>
>>>
>>>  -- 
>> 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]<javascript:>
>> .
>> To post to this group, send email to 
>> [email protected]<javascript:>
>> .
>> Visit this group at 
>> http://groups.google.com/group/google-visualization-api?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to