I recently able to work out how to filter date range from calendar to display in asp chart from database, but i tried converting to using ajax and i am struggling to convert.
Tried googling and stuff but it doesn't really show me much of it.
I hope you guys might be able to help me out.
This is the code behind for my chart
protected void BindChart1()
{
string cs = ConfigurationManager.ConnectionStrings["impgardenConnectionString"].ConnectionString;
using (MySqlConnection con = new MySqlConnection(cs))
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
con.Open();
using (MySqlCommand com = new MySqlCommand("SELECT Id,Temperature,ReadDateTime FROM smartterranium WHERE ReadDateTime BETWEEN @ViewDateFrom and @ViewDateTo ", con))
{
com.Parameters.AddWithValue("@ViewDateFrom", tbViewDateFrom.Text);
com.Parameters.AddWithValue("@ViewDateTo", tbViewDateTo.Text);
using (MySqlDataReader reader = com.ExecuteReader())
{
while (reader.Read())
{
LineChart1.Series.Add(new AjaxControlToolkit.LineChartSeries { LineColor = "#3dc0f4", Name = "Suppliers" });
}
}
}
}
}This is the ajax datepicker.
<asp:Label ID="lblDateFrom" runat="server" Text="View Date From:"></asp:Label> <asp:TextBox ID="tbViewDateFrom" runat="server" AutoPostBack="True"></asp:TextBox><ajaxToolkit:CalendarExtender ID="CalExtViewDateFrom" runat="server" BehaviorID="CalExtViewDateFrom" TargetControlID="tbViewDateFrom" Format="dd/MM/yy" /><asp:Label ID="lblDateTo" runat="server" Text="View Date To:"></asp:Label> <asp:TextBox ID="tbViewDateTo" runat="server" AutoPostBack="True"></asp:TextBox><ajaxToolkit:CalendarExtender ID="CalExtViewDateTo" runat="server" BehaviorID="CalExtViewDateTo" TargetControlID="tbViewDateTo" Format="dd/MM/yy" /><asp:Button ID="btnSubmit" runat="server" Text="Filter" OnClick="btnSubmit_Click" />
This is the ajax calendar i want to use
ajaxToolkit:LineChart ID="LineChart1" runat="server"
ChartTitleColor="#0E426C" CategoryAxisLineColor="#D08AD9"
ValueAxisLineColor="#D08AD9" BaseLineColor="#A156AB"
ChartTitle="Temperature"
ChartHeight="300" ChartWidth="450" ChartType="Basic"></ajaxToolkit:LineChart>Thanks alot!