Click here to Skip to main content
15,887,338 members
Home / Discussions / C#
   

C#

 
GeneralRe: Property with "get" only, or a separate method? Pin
OriginalGriff18-Apr-14 8:32
mveOriginalGriff18-Apr-14 8:32 
AnswerRe: Property with "get" only, or a separate method? Pin
Ravi Bhavnani18-Apr-14 8:16
professionalRavi Bhavnani18-Apr-14 8:16 
GeneralRe: Property with "get" only, or a separate method? Pin
Matt U.18-Apr-14 8:19
Matt U.18-Apr-14 8:19 
GeneralRe: Property with "get" only, or a separate method? Pin
Ravi Bhavnani18-Apr-14 8:59
professionalRavi Bhavnani18-Apr-14 8:59 
Questionmarching cubes Pin
Member 1071125918-Apr-14 7:25
Member 1071125918-Apr-14 7:25 
AnswerRe: marching cubes Pin
OriginalGriff18-Apr-14 8:10
mveOriginalGriff18-Apr-14 8:10 
QuestionBackground Substraction and HOG Pin
Member 1042078418-Apr-14 5:42
Member 1042078418-Apr-14 5:42 
QuestionDisplay graph from selected dropdownlist and radiobutton Pin
Syafiqah Zahirah18-Apr-14 0:43
Syafiqah Zahirah18-Apr-14 0:43 
Hye..can anyone know how I can I display graph from selected dropdownlist and radiobutton. My code like below:

XML
<table>
    <tr>
    <td><h4><span>Choose House:</span></h4></td>
    <td class="style4">
        <asp:DropDownList ID="DropDownList1" runat="server" Height="16px" Width="114px">
        </asp:DropDownList>
        </td>
        <td class="style5"></td>
        <td class="style6"></td>
    </tr>

    <tr>
    <td><h4><span>View:</span></h4></td>
    <td class="style4">
        <asp:RadioButton ID="LineRadioButton" runat="server" Text="Line Graph" />
        </td>
        <td class="style4">
            <asp:RadioButton ID="PieButton" runat="server" Text="Pie Chart" />
        </td>
        <td class="style4">
            <asp:RadioButton ID="BarRadioButton" runat="server" Text="Bar Graph" />
        </td>
    </tr>
    </table>
    <asp:Chart ID="Chart1" runat="server" Height="394px" Width="937px"
        BackColor="PaleTurquoise">
        <Titles>
            <asp:Title ShadowOffset="3" Name="Muhsroom House Environment" />
        </Titles>
       <Legends>
         <asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="False" Name="TempIn" LegendStyle="Row" />
         <asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="False" Name="TempOut" LegendStyle="Row" />
         <asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="False" Name="Humidity" LegendStyle="Row" />
      </Legends>
        <Series>
                <asp:Series legendtext="Temperature In" ChartType="Line" Name="TempIn"> </asp:Series>
                <asp:Series legendtext="Temperature Out"  ChartType="Line" Name="TempOut"> </asp:Series>
                <asp:Series legendtext="Humidity"  ChartType="Line" Name="Humidity"> </asp:Series>
         </Series>
            <borderskin backcolor="Olive" bordercolor="Olive" skinstyle="Emboss" />
            <ChartAreas>
                <asp:ChartArea Name="ChartArea1">
                 <AxisY Title="Degrees" ></AxisY>
                 <AxisX Title="Time"></AxisX>
                 <Area3DStyle IsClustered="True"></Area3DStyle>
                </asp:ChartArea>
            </ChartAreas>
    </asp:Chart>
    <br />


     <table>
     <tr>
     <td>
         TempIn: <asp:TextBox ID="TempInTextBox" runat="server" Width="20px"></asp:TextBox>
         </td>
     <td>
         TempOut:<asp:TextBox ID="TempOutTextBox" runat="server" Width="20px"></asp:TextBox>
         </td>
     <td>
         Humidity:<asp:TextBox ID="HumidTextBox" runat="server" Width="20px"></asp:TextBox>
         </td>
     </tr>
     </table>


Coding aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Web.UI.DataVisualization.Charting;

namespace PSM_Mushroom
{
public partial class Graph : System.Web.UI.Page
{

SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=MushroomHouse;Integrated Security=True");

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string CS = ConfigurationManager.ConnectionStrings["MushroomHouse"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{

SqlCommand cmd = new SqlCommand("SELECT id, Name FROM TMushroomHouse", con);

con.Open();

DropDownList1.DataSource = cmd.ExecuteReader();
DropDownList1.DataTextField = "Name";
DropDownList1.DataValueField = "id";
DropDownList1.DataBind();
}
}

}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{

String strConnString = ConfigurationManager.ConnectionStrings["MushroomHouse"].ConnectionString;

string sql = "SELECT Environmnets.TempIn, Environmnets.tempOut, Environmnets.humidity, FROM Environmnets INNER JOIN TDevice ON Environmnets.Deviceid = TDevice.id INNER JOIN TMushroomHouse ON TDevice.MushroomHouseId = TMushroomHouse.id WHERE TMushroomHouse.id=@id";

using (SqlConnection con = new SqlConnection(strConnString))
using (SqlCommand cmd = new SqlCommand(sql, con))
//SqlDataReader dr = cmd.ExecuteReader();
{
cmd.Parameters.AddWithValue("@id", DropDownList1.Text);

con.Open();

using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
TempInTextBox.Text = dr.GetValue(0).ToString();
TempOutTextBox.Text = dr.GetValue(1).ToString();
HumidTextBox.Text = dr.GetValue(2).ToString();


Chart1.Series["TempIn"].Points.AddXY(DateTime.Now.ToShortTimeString(),Double.Parse(TempInTextBox.Text));
Chart1.Series["TempOut"].Points.AddXY(DateTime.Now.ToShortTimeString(),Double.Parse(TempOutTextBox.Text));
Chart1.Series["Humidity"].Points.AddXY(DateTime.Now.ToShortTimeString(),Double.Parse(HumidTextBox.Text));
}
}
}

}


}
QuestionCS1525: Invalid expression term '<' error Pin
Member 1075622017-Apr-14 6:12
Member 1075622017-Apr-14 6:12 
AnswerRe: CS1525: Invalid expression term '<' error Pin
Wes Aday17-Apr-14 6:29
professionalWes Aday17-Apr-14 6:29 
GeneralRe: CS1525: Invalid expression term '<' error Pin
OriginalGriff17-Apr-14 8:26
mveOriginalGriff17-Apr-14 8:26 
GeneralRe: CS1525: Invalid expression term '<' error Pin
Richard MacCutchan17-Apr-14 22:16
mveRichard MacCutchan17-Apr-14 22:16 
Questionquestion abot WPF Button Pin
Member 1026763017-Apr-14 3:44
Member 1026763017-Apr-14 3:44 
GeneralRe: question abot WPF Button Pin
Richard MacCutchan17-Apr-14 5:32
mveRichard MacCutchan17-Apr-14 5:32 
GeneralRe: question abot WPF Button Pin
Richard Andrew x6417-Apr-14 8:51
professionalRichard Andrew x6417-Apr-14 8:51 
QuestionHow Do I show Users datail information like Full name,dob etc in a web page stored in database apart from username? Pin
krish099117-Apr-14 1:57
krish099117-Apr-14 1:57 
AnswerRe: How Do I show Users datail information like Full name,dob etc in a web page stored in database apart from username? PinPopular
Pete O'Hanlon17-Apr-14 2:08
mvePete O'Hanlon17-Apr-14 2:08 
AnswerRe: How Do I show Users datail information like Full name,dob etc in a web page stored in database apart from username? Pin
Tom Marvolo Riddle17-Apr-14 2:21
professionalTom Marvolo Riddle17-Apr-14 2:21 
QuestionSee the Activity monitor of employers Pin
Hrishabh Kushwah17-Apr-14 0:56
professionalHrishabh Kushwah17-Apr-14 0:56 
AnswerRe: See the Activity monitor of employers Pin
Wes Aday17-Apr-14 1:51
professionalWes Aday17-Apr-14 1:51 
AnswerRe: See the Activity monitor of employers Pin
Eddy Vluggen17-Apr-14 10:20
professionalEddy Vluggen17-Apr-14 10:20 
Questioni want to know how to compare the two gridviews values Pin
Member 1075542716-Apr-14 21:46
Member 1075542716-Apr-14 21:46 
AnswerRe: i want to know how to compare the two gridviews values Pin
OriginalGriff16-Apr-14 22:04
mveOriginalGriff16-Apr-14 22:04 
AnswerRe: i want to know how to compare the two gridviews values Pin
Chris Quinn16-Apr-14 23:04
Chris Quinn16-Apr-14 23:04 
Questionhow to get and compare values between two gridviews Pin
Member 1075542716-Apr-14 21:37
Member 1075542716-Apr-14 21:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.