Help On Calendar Date Selected

Posted by Vijayar under C# on 12/6/2011 | Points: 10 | Views : 1498 | Status : [Member] | Replies : 1
I have a table called events with the fields event title,event date,description fields.I am inserting event date and description into this table.Now I have taken another form and placed a calendar. Now when i select a date in the calendar placed ,if any event exist on that particular date,then the description stored for that day should be displayed in a label.How to compare the selected date with each and every row date in a table.Please help me



Posted by: Varung on: 12/7/2011 [Member] Starter | Points: 25

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
string date = Calendar1.SelectedDate.ToShortDateString();
string query="select description from tablename where event date='"+date+"";
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
cmd.CommandText = query;
string result = cmd.ExecuteScalar().ToString();
Label1.Text = result;


Vijayar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response