我需要事件日历代码方面的帮助 [英] i want help in event calender code
本文介绍了我需要事件日历代码方面的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有EventCalendercode我将其与登录相关,例如,当用户登录时,如果单击日期,则他/她设置的唯一事件将显示在gridview中
这是我的桌子
I have EventCalendercode I related it to login for example when user login when h click on date only event he/she set is displayed in gridview
this is my table
ID int
Email varchar(500)
Password varchar(500)
Name varchar(500)
Country varchar(500)
LastLogin datetime
RegisterDate datetime
Description Varchar(500)
ImageName varchar(500)
EventName varchar(500)
EventDate datetime
SqlConnection mycn;
SqlDataAdapter myda;
DataSet ds = new DataSet();
DataSet dsSelDate;
String strConn;
protected void Page_Load(object sender, EventArgs e)
{
strConn = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\omar\\Documents\\Visual Studio 2005\\WebSites\\Project2\\App_Data\\Database.mdf;Integrated Security=True;User Instance=True";
mycn = new SqlConnection(strConn);
myda = new SqlDataAdapter("Select * FROM Events", mycn);
myda.Fill(ds, "Table");
}
protected void CalenderDRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
{
// If the month is CurrentMonth
if (!e.Day.IsOtherMonth)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
if ((dr["EventDate"].ToString() != DBNull.Value.ToString()))
{
DateTime dtEvent = (DateTime)dr["EventDate"];
if (dtEvent.Equals(e.Day.Date))
{
e.Cell.BackColor = Color.PaleVioletRed;
}
}
}
}
//If the month is not CurrentMonth then hide the Dates
else
{
e.Cell.Text = "";
}
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
myda = new SqlDataAdapter("Select * from Events where EventDate=''" + Calendar1.SelectedDate.ToString("s") + "''", mycn);
dsSelDate = new DataSet();
myda.Fill(dsSelDate, "AllTables");
if (dsSelDate.Tables[0].Rows.Count == 0)
{
DataGrid1.Visible = false;
}
else
{
DataGrid1.Visible = true;
DataGrid1.DataSource = dsSelDate;
DataGrid1.DataBind();
}
}
请帮助我做出逻辑,例如,如果他单击日期时在网格视图中显示了xyz@yahoo.com仅登录日期设置的事件,则该视图会显示在网格视图中
[已编辑]代码在前置"标签中被阻止[/已编辑]
please help me to make the logic for example if xyz@yahoo.com login only events he set on date is displayed in grid view when he click on date
Code is blocked in "pre" tags[/Edited]
推荐答案
使用SQL语句过滤检索到的项目.让数据库先完成这项工作然后再亲自尝试是更好的选择.
您需要对您的陈述进行参数化,如下所示:
Use the SQL statement to filter down the items retrieved. It is invairiably better to let the DB do this work then try it yourself.
You need to parametise your statement, something like this:
"Select * FROM Events WHERE email = @email AND eventDate = @eventDate"
此链接 [
This link[^] should help.
这篇关于我需要事件日历代码方面的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文