2012-05-07 67 views
0

所以我试图创建一个日历工具,从SQL数据库中提取日期。C#日历工具ASP.NET

我创建一个TableAdapter这是在这里:http://bit.ly/KRaTvr

这是ASP的小一点我要创建我的日历:

<asp:Calendar ID="calEvents" runat="server"> </asp:Calendar>  

然后我有C#在我的项目使用通过拉动信息。

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 BreakyBottomTableAdapters; 

public partial class Events : System.Web.UI.Page 
{ 

    protected void Page_Load(object sender, EventArgs e) 
    { 

     //Data Table 
     BreakyBottom table; 
     //Table Adapter 
     BreakyBottomTableAdapters.ScheduleDate ta; 
     ta = new BreakyBottomTableAdapters.ScheduleDate(); 
     //Populate the table using the Table Adapter passing current date 
     table = ta.GetData(e.Day.Date); 
     //Check the number of rows in the data table 
     if (table.Rows.Count > 0) 
     { 
      //Change the background colour to gray 
      e.Cell.BackColor = System.Drawing.Color.Gray; 
      //Allow the Day to be selected 
      e.Day.IsSelectable = true; 
     } 


    } 
} 

现在我知道我失去了一些东西,但我不能为我的数字的生活,它是什么。

以下是编译错误,我得到的截图:http://bit.ly/ISuVsT - 我知道我可能失去了一些东西出奇明显,但任何援助将不胜感激。

问候

回答

1

编译器会提醒您EventArgs没有你,显然是在代码中使用不当的任何成员称为Day

protected void Page_Load(object sender, EventArgs e) 
{ 
    .... 
    table = ta.GetData(e.Day.Date); //WRONG: Day is not a member of EventArgs 
} 

如果这个想法是使用当前日期,如你所说,那么这样做:

table = ta.GetData(DateTime.Now); 
+0

感谢您的快速反应伊卡洛斯我实际上试过后,我张贴并结束得到这个错误。 “为“插入数据库/ TableAdapter的这里最好的重载的方法匹配具有一些无效参数” 这我目前正在寻找中,但你说的是完全合乎逻辑的。现在只是不太确定为什么我得到这个错误。 – user1380485