<%
@ Page Language="vb" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="~/Diagramm02.aspx.vb" Inherits="_Default"%>
<%
@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>
<%
@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%
@ Register Assembly="Telerik.Charting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d14f3dcc8e3e8763" Namespace="Telerik.Charting" TagPrefix="telerik" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolderDisAnContent" runat="Server">
<asp:ScriptManager id="ScriptManager1" runat="server"></asp:ScriptManager>
<script type="text/javascript">
<!--
function OnPopupOpening(sender, args)
{
// TraceEvent("OnPopupOpening fired by " + sender.get_id() + "<br />");
var firstDatePicker = $find("<%= RadDatePicker1.ClientID %>");
// process the event only for the second datepicker
if (sender.get_id() == firstDatePicker.get_id())
return;
// process the event only if the second datepicker is empty and the first is not
if (sender.isEmpty() == false || firstDatePicker.isEmpty() == true)
return;
var dateToNavigate = GetDateToNavigate();
var secondDatePicker = $find("<%= RadDatePicker2.ClientID %>");
}
function OnPopupClosing(sender, args)
{
// TraceEvent("OnPopupClosing fired by " + sender.get_id() + "<br />");
// process the event only for the second datepicker
if (sender.get_id() == "<%= RadDatePicker1.ClientID %>")
return;
// process the event only if the first datepicker is not empty
var firstDatePicker = $find("<%= RadDatePicker1.ClientID %>");
if (firstDatePicker.isEmpty() == true)
return;
var dateArr = sender.get_calendar().get_selectedDates();
if(dateArr[0])
{
var date = new Date(dateArr[0][0], dateArr[0][1] - 1, dateArr[0][2]);
var dateToCompare = firstDatePicker.get_selectedDate();
if(date < dateToCompare)
{
alert(
"Bitte, wählen Sie einen späteren Endpunkt aus!");
args.set_cancel(
true);
}
}
}
function GetDateToNavigate()
{
var firstDatePicker = $find("<%= RadDatePicker1.ClientID %>");
var dateToNavigate = firstDatePicker.get_selectedDate();
return dateToNavigate;
}
function OnDateSelected(sender, e)
{
if (e.get_newDate() != null)
{
// TraceEvent("OnDateSelected: " + e.get_newDate().toDateString() + " selected in " + sender.get_id() + "<br />");
}
else
{
// TraceEvent("OnDateSelected: Date cleared in " + sender.get_id() + "<br />");
}
}
var output;
/* function TraceEvent(message)
{
if (!output)
{
output = document.getElementById("eventLog");
}
if (output)
{
var now = new Date();
var str = "[" + now.toLocaleTimeString() + "] "
+ message;
output.innerHTML = output.innerHTML + (output.innerHTML ? "\n" : "") + str;
output.scrollTop = 10000000;
}
}
*/
-->
</script>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/chart.mdb" SelectCommand="SELECT Datum, Wert FROM Messwerte WHERE (Id = 1)" DataSourceMode="DataReader"></asp:AccessDataSource>
<telerik:RadSplitter ID="RadSplitter1" runat="server" ResizeMode="EndPane" LiveResize="false" Height="500" Width="830">
<telerik:RadSplitBar ID="RadSplitbar3" runat="server" CollapseMode="Forward" />
<telerik:RadPane ID="navigationPane" runat="server" Scrolling="none">
<telerik:RadChart ID="RadChart1" runat="server" CssClass="RadChart" DataSourceID="AccessDataSource1" DefaultType="Line" CreateImageMap="False">
<Series>
<telerik:ChartSeries DataYColumn="Wert" Name="Wert" Type="Line">
<Appearance>
<FillStyle MainColor="0, 0, 0">
</FillStyle>
<LabelAppearance Visible="False">
</LabelAppearance>
</Appearance>
</telerik:ChartSeries>
</Series>
</telerik:RadChart>
</telerik:RadPane>
<telerik:RadSplitBar ID="RadSplitbar1" runat="server" CollapseMode="Forward" />
<telerik:RadPane ID="RadPane2" runat="server" Scrolling="none" Width="300">
<div class="TitleNews"><b>Einstellungen</b><br /></div>
<telerik:RadSplitter ID="RadSplitter2" runat="server" LiveResize="false" Orientation="Horizontal" CssClass="Telerik">
<telerik:RadPane ID="topPane" runat="server" Height="150" Scrolling="both">
<table>
<tr>
<td><asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Size="Medium">Startdatum:</asp:Label>
</td>
<td><telerik:RadDatePicker ID="RadDatePicker1" runat="server" Culture="German (Germany)" Width="150px" SelectedDate="2008-01-01" >
<ClientEvents OnPopupOpening="OnPopupOpening" OnPopupClosing="OnPopupClosing" OnDateSelected="OnDateSelected">
</ClientEvents>
<DateInput runat="server" InvalidStyleDuration="100" SelectedDate="2008-01-01">
</DateInput>
</telerik:RadDatePicker>
</td>
</tr>
<tr>
<td><asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Size="Medium">Enddatum:</asp:Label>
</td>
<td><telerik:RadDatePicker ID="RadDatePicker2" runat="server" Culture="German (Germany)" Width="150px" SelectedDate="2008-01-02" >
<ClientEvents OnPopupOpening="OnPopupOpening" OnPopupClosing="OnPopupClosing" OnDateSelected="OnDateSelected">
</ClientEvents>
<DateInput runat="server" InvalidStyleDuration="100" SelectedDate="2008-01-02">
</DateInput>
</telerik:RadDatePicker>
</td>
</tr>
<tr>
<td colspan="2"><label for="dropDownCategory">
<asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Size="Medium">Energiezähler:</asp:Label>
</label>
</td>
</tr>
<tr>
<td colspan="2"><asp:DropDownList ID="dropDownCategory" runat="server" AutoPostBack="True" OnSelectedIndexChanged="dropDownCategory_SelectedIndexChanged" Width="225">
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2" align="center"><asp:Button ID="Button1" runat="server" Text="Start" />
</td>
</tr>
</table>
</telerik:RadPane>
<telerik:RadSplitBar ID="RadSplitbar2" runat="server" CollapseMode="Forward" />
<telerik:RadPane ID="contentPane" runat="server" Scrolling="Y">
<!-- Grid für Daten der Zähler -->
<asp:AccessDataSource ID="AccessDataSource2" runat="server" DataFile="~/App_Data/Konfiguration.mdb" SelectCommand="SELECT Zaehlernummer, Einbaudatum, Typenbezeichnung, Anlagenkennzeichnung, Bezugsflaeche, Wandlerkonstante, Ausbaudatum FROM Zaehler WHERE (Zaehlernummer = 'BERT1/1/22/684801/2/81')"></asp:AccessDataSource>
<asp:DataList ID="DataList1" runat="server" DataSourceID="AccessDataSource2">
<ItemTemplate>
Zaehlernummer:
<asp:Label ID="ZaehlernummerLabel" runat="server" Text='<%# Eval("Zaehlernummer") %>'></asp:Label><br />
Einbaudatum:
<asp:Label ID="EinbaudatumLabel" runat="server" Text='<%# Eval("Einbaudatum") %>'></asp:Label><br />
Typenbezeichnung:
<asp:Label ID="TypenbezeichnungLabel" runat="server" Text='<%# Eval("Typenbezeichnung") %>'></asp:Label><br />
Anlagenkennzeichnung:
<asp:Label ID="AnlagenkennzeichnungLabel" runat="server" Text='<%# Eval("Anlagenkennzeichnung") %>'></asp:Label><br />
Bezugsflaeche:
<asp:Label ID="BezugsflaecheLabel" runat="server" Text='<%# Eval("Bezugsflaeche") %>'></asp:Label><br />
Wandlerkonstante:
<asp:Label ID="WandlerkonstanteLabel" runat="server" Text='<%# Eval("Wandlerkonstante") %>'></asp:Label><br />
Ausbaudatum:
<asp:Label ID="AusbaudatumLabel" runat="server" Text='<%# Eval("Ausbaudatum") %>'></asp:Label><br />
<br />
</ItemTemplate>
</asp:DataList></telerik:RadPane>
</telerik:RadSplitter>
</telerik:RadPane>
</telerik:RadSplitter>
</asp:Content>
-------------------------------------------------------------------------------------------
My Diagramm02.aspx.vb File
-------------------------------------------------------------------------------------------
Imports
System.Data.OleDb
Partial
Public Class _Default
Inherits System.Web.UI.Page
Protected dbCon As OleDbConnection
Protected dbCon2 As OleDbConnection
Private Sub InitDropDownCategory(ByVal dbCon As OleDbConnection)
Dim adapter As New OleDbDataAdapter("SELECT * FROM Category", dbCon)
Dim ds As New DataSet()
adapter.Fill(ds)
dropDownCategory.Items.Clear()
Dim dbRow As DataRow
For Each dbRow In ds.Tables(0).Rows
If Not (dbRow("name") Is Nothing) Then
dropDownCategory.Items.Add(
CStr(dbRow("name")))
End If
Next dbRow
End Sub 'InitDropDownCategory
Protected Sub dropDownCategory_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
' dbCon = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/Chart/Examples/DataBinding/Data/chart.mdb"))
' dbCon.Open()
' UpdateRadChart1(dbCon)
' dbCon.Close()
' dbCon2 = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/Chart/Examples/DataBinding/Data/Konfiguration.mdb"))
' dbCon2.Open()
'UpdateDataList1(dbCon2)
' dbCon2.Close()
End Sub 'dropDownCategory_SelectedIndexChanged
Protected Sub dropDownYears_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
dbCon =
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/App_Data/chart.mdb"))
dbCon.Open()
UpdateRadChart1(dbCon)
dbCon.Close()
End Sub 'dropDownYears_SelectedIndexChanged
Private Sub InitRadChart1()
RadChart1.DataSourceID = AccessDataSource1.ID
RadChart1.ChartTitle.TextBlock.Text = dropDownCategory.SelectedItem.Text
End Sub
Private Sub UpdateDataList1(ByVal dbCon2 As OleDbConnection)
Dim sqlString As String
' Dim DropDownAuswahl As String = dropDownCategory.SelectedIndex + 1
Dim DropDownAuswahl As String = dropDownCategory.SelectedValue
'DropDownAuswahl = "'BERT1/1/22/684801/2/81'"
sqlString =
"SELECT Zaehlernummer, Einbaudatum, Typenbezeichnung, Anlagenkennzeichnung, Bezugsflaeche, Wandlerkonstante, Ausbaudatum FROM Zaehler WHERE (Zaehlernummer = " + DropDownAuswahl + ");"
AccessDataSource2.SelectCommand = sqlString
End Sub
Private Sub UpdateRadChart1(ByVal dbCon As OleDbConnection)
Dim sqlString As String
Dim DropDownAuswahl As String = dropDownCategory.SelectedIndex + 1
Dim StartDate As String = "01.01.2008"
Dim EndDate As String = "31.10.2008"
StartDate = RadDatePicker1.SelectedDate
EndDate = RadDatePicker2.SelectedDate
sqlString =
"SELECT [Id], [Datum], [Wert] FROM Messwerte WHERE ((Id=" + DropDownAuswahl + ") AND (Datum > '" + StartDate + "') AND (Datum < '" + EndDate + "'));"
RadChart1.Series.Clear()
RadChart1.DataGroupColumn =
"Id"
'RadChart1.AutoLayout = "True"
'RadChart1.ClientSettings.ScrollMode = Web.UI.ChartClientScrollMode.XOnly
'RadChart1.ClientSettings.EnableZoom = "False"
'RadChart1.ClientSettings.XScale = "10"
' Update the Data source control's select command.
AccessDataSource1.SelectCommand = sqlString
' Set additional properties and settings for the chart.
RadChart1.ChartTitle.TextBlock.Text = dropDownCategory.SelectedItem.Text
'RadChart1.PlotArea.XAxis.DataLabelsColumn = "Datum"
End Sub 'UpdateRadChart1
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
dbCon =
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/App_Data/chart.mdb"))
dbCon.Open()
InitDropDownCategory(dbCon)
InitRadChart1()
dbCon.Close()
End If
RadChart1.Skin =
"LightBlue"
RadChart1.Width =
"500"
RadChart1.Height =
"500"
RadChart1.PlotArea.XAxis.Visible = Telerik.Charting.Styles.ChartAxisVisibility.False
RadChart1.Legend.Visible =
False
End Sub 'Page_Load
Protected Sub RadChart1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadChart1.DataBound
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
dbCon =
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/App_Data/chart.mdb"))
dbCon.Open()
UpdateRadChart1(dbCon)
dbCon.Close()
dbCon2 =
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/App_Data/Konfiguration.mdb"))
dbCon2.Open()
'UpdateDataList1(dbCon2)
dbCon2.Close()
End Sub
End
Class 'DefaultVB
-------------------------------------------------------------------------------------------
My MasterPage.master
-------------------------------------------------------------------------------------------
<%
@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<%
@ Register Assembly="RadTreeView.Net2" Namespace="Telerik.WebControls" TagPrefix="radT" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<title>Energiemanagment - EMSY</title>
<link href="css/emsy.css" rel="stylesheet" type="text/css" />
</
head>
<
body>
<form id="form1" runat="server">
<div>
<table style="width:100%">
<tr>
<td colspan="3" align=center style="height: 89px">
<div id="header">Energiemanagement - EMSY<div id="slogan">
</div>
</td>
</tr>
<tr>
<td style="width: 231px" valign=top>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
<script language="javascript" type="text/javascript">
function SaveSelectedNodes(node) {
var i;
var selectedNodes = "";
for(i=0; i<node.TreeView.AllNodes.length; i++)
{
if(node.TreeView.AllNodes[i].Expanded)
selectedNodes += node.TreeView.AllNodes[i].Value +
"*";
}
Set_Cookie(
"test",selectedNodes);
}
function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );
/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );
document.cookie = name +
"=" +escape( value ) +
( ( expires ) ?
";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ?
";path=" + path : "" ) +
( ( domain ) ?
";domain=" + domain : "" ) +
( ( secure ) ?
";secure" : "" );
}
</script>
<div id="DisAn_PageCell">
<!-- Left Tree Menu-->
<div id="DisAn_TreeContainer">
<radT:RadTreeView
ID="RadTree1"
Skin = "Square/3DClassic"
ShowLineImages="False"
ExpandDelay="0"
AfterClientToggle="SaveSelectedNodes"
runat="server">
</radT:RadTreeView>
</div>
</div>
<!-- End Page Cell-->
</asp:contentplaceholder>
</td>
<td colspan="2" valign="top">
<asp:ContentPlaceHolder ID="ContentPlaceHolderDisAnContent" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
<br />
</div>
</form>
</
body>
</
html>
I’m using RadGrid for ASP.NET AJAX with LinqDataSource.
I’m amazed with amount of functionality I can accomplish in this combination with just declarative programming in ASCX and without single line in code behind.
What I really like is that sorting and paging is done on SQL server. Here is example of T-SQL I got from SQL Server Profiler:
exec sp_executesql N'SELECT [t1].[Id], [t1].[ParentId], [t1].[Name]
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY [t0].[Name]) AS [ROW_NUMBER], [t0].[Id], [t0].[ParentId], [t0].[Name]
FROM [dbo].[Things] AS [t0]
) AS [t1]
WHERE [t1].[ROW_NUMBER] BETWEEN @p0 + 1 AND @p0 + @p1
ORDER BY [t1].[ROW_NUMBER]',N'@p0 int,@p1 int',@p0=8,@p1=8
Now, I would like to utilize RadGrid filtering with AllowFilteringByColumn="True".
When I execute some filter I got this T-SQL code in SQL Profiler:
SELECT TOP (2147483647) [t0].[Id], [t0].[ParentId], [t0].[Name]
FROM [dbo].[Things] AS [t0]
ORDER BY [t0].[Name]
This means that in this case filtering and paging is not done by SQL server, but on web server with in RadGrid control. In this case it is possible that huge amount of rows is sent form SQL to web server and I would like to avoid this too. (I see that with canretrievealldata="False" I can preserve SQL Server paging, but in this case filtering is preformed only over current page, so this is not a solution for me.)
If I understand correctly by default data filtering is executed with in RadGrid control with LINQ.
I would like to use LINQ to SQL for this in my project because I think it is more optimal.
Do I miss something here?
What is best way to accomplish use of LINQ to SQL with RadGrid for ASP.NET AJAX and LinqDataSource for filtering also?
can anyone gve me the reason for this error. While i m using 3 level her. RadGrid
For some reason if I define the ClientCallBack function of a window with java script it does not execute, If I define the same function as the client call back function of the RadWindowManager it operates properly.
var radWindow = window.radopen(url, null );
radWindow.SetTitle(title);
radWindow.ClientCallBackFunction = "PCEReturn";
alert(radWindow.ClientCallBackFunction);
Any thoughts?
Kyle