<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"
AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Vehicle"
DataValueField="Vehicle" Height="17px"
onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="144px">
<asp:ListItem Selected="True">Select vehicle</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:rentcarConnectionString %>"
SelectCommand="SELECT DISTINCT [Vehicle] FROM [booking]">
</asp:SqlDataSource>
<asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC"
BorderColor="#FFCC66" BorderWidth="1px" DayNameFormat="Shortest"
Font-Names="Verdana" Font-Size="8pt" ForeColor="#663399" Height="336px"
ondayrender="Calendar1_DayRender" ShowGridLines="True" Width="902px">
<DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
<OtherMonthDayStyle ForeColor="#CC9966" />
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<SelectorStyle BackColor="#FFCC66" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
<TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
</asp:Calendar>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
Coding
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class Default14 : System.Web.UI.Page
{
public string ss;
protected void Page_Load(object sender, EventArgs e)
{
ss = ConfigurationManager.ConnectionStrings["rentcarConnectionString"].ConnectionString;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.Items.Clear();
SqlConnection con = new SqlConnection(ss);
con.Open();
SqlCommand cmd = new SqlCommand("select * from booking where Vehicle='" + DropDownList1.SelectedValue.ToString() + "'", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
string sd = dr.GetValue(2).ToString();
//Label1.Text = "sd;
List<string> lists = new List<string>();
lists.Add(sd);
foreach (string s in lists)
{
DropDownList2.Items.Add(s);
Calendar1.SelectedDates.Add(Convert.ToDateTime(s));
}
}
dr.Close();
con.Close();
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.IsSelected)
{
e.Cell.Text = "booked";
}
}
}
to perform any action on selecting date then code
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
string sds =Calendar1.SelectedDate.ToShortDateString();
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True"
AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Vehicle"
DataValueField="Vehicle" Height="17px"
onselectedindexchanged="DropDownList1_SelectedIndexChanged" Width="144px">
<asp:ListItem Selected="True">Select vehicle</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:rentcarConnectionString %>"
SelectCommand="SELECT DISTINCT [Vehicle] FROM [booking]">
</asp:SqlDataSource>
<asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC"
BorderColor="#FFCC66" BorderWidth="1px" DayNameFormat="Shortest"
Font-Names="Verdana" Font-Size="8pt" ForeColor="#663399" Height="336px"
ondayrender="Calendar1_DayRender" ShowGridLines="True" Width="902px">
<DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
<NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
<OtherMonthDayStyle ForeColor="#CC9966" />
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<SelectorStyle BackColor="#FFCC66" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
<TodayDayStyle BackColor="#FFCC66" ForeColor="White" />
</asp:Calendar>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
Coding
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public partial class Default14 : System.Web.UI.Page
{
public string ss;
protected void Page_Load(object sender, EventArgs e)
{
ss = ConfigurationManager.ConnectionStrings["rentcarConnectionString"].ConnectionString;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList2.Items.Clear();
SqlConnection con = new SqlConnection(ss);
con.Open();
SqlCommand cmd = new SqlCommand("select * from booking where Vehicle='" + DropDownList1.SelectedValue.ToString() + "'", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
string sd = dr.GetValue(2).ToString();
//Label1.Text = "sd;
List<string> lists = new List<string>();
lists.Add(sd);
foreach (string s in lists)
{
DropDownList2.Items.Add(s);
Calendar1.SelectedDates.Add(Convert.ToDateTime(s));
}
}
dr.Close();
con.Close();
}
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.IsSelected)
{
e.Cell.Text = "booked";
}
}
}
to perform any action on selecting date then code
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
string sds =Calendar1.SelectedDate.ToShortDateString();
}
No comments:
Post a Comment