0

我一直在 VS Studio for Web 2012 上的这个网站上工作。其中大部分是 HTML 和 ASP,但我已经包含了一个从 SourceForge 下载的 DayPilot 日历。显然,我必须将日历 DataBind 到我的 SQL 服务器,以便用户可以登录并在日历上为自己留出时间。我几乎使用了我在网上可以找到的所有推荐代码,但似乎没有一个在日历页面上有效。这是aspx页面和aspx.vb页面代码:(aspx页面)

    <%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master"   AutoEventWireup="false" CodeFile="calendarpg.aspx.vb" Inherits="_Default" %>

    <%@ Register Assembly="DayPilot" Namespace="DayPilot.Web.Ui" TagPrefix="DayPilot" %>

   <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script type="text/javascript" src="<%=ResolveUrl("~/Scripts/DayPilot/calendar.js")%>">         
    </script>
    <style type="text/css">
            .auto-style8 {
            font-size: large;
        }
    </style>
    <link type="text/css" rel="stylesheet" href="<%=ResolveUrl("~/Themes/themes.css")%>" />
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    dbo.BasicData
    <DayPilot:DayPilotNavigator ID="DayPilotNavigator1" runat="server" />
    <DayPilot:DayPilotCalendar ID="DayPilotCalendar1" runat="server" Days="7" EventMoveJavaScript="alert('eventMove(e.start(), newEnd')" BackColor="#CCFFFF" DataStartField="null"></DayPilot:DayPilotCalendar>
    <DayPilot:DayPilotScheduler ID="DayPilotScheduler1" runat="server">     
    </DayPilot:DayPilotScheduler>
    <br />
    <h1><strong>Scheduling</strong></h1>
    <span class="auto-style8">Requests are made via the Calendar for each of the respective Sandboxes. 
    A minimum of 24-hour notice is rquired when making a request to allow
    time for preparation of a Sandbox, 
    <br />
    time zone differences, and to resolve any
    scheduling conflicts.
    <br />
    <br />
    The process for booking is similar to booking a conference room.
    <br />
    <br />
    Choose a day and time that is open, for the Sandbox you're interested in using,
    then choose the open hours that work best for your schedule. </span>
    </asp:Content>

(aspx.vb 页面)

Partial Class _Default
Inherits System.Web.UI.Page
'Declaration
Public Event DataBinding As EventHandler

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DayPilotCalendar1.DataSource = getData()
DataBind()
End Sub

Public Function getData() As Data.DataTable
Dim dt As Data.DataTable
dt = New Data.DataTable

dt.Columns.Add("start", GetType(DateTime))
dt.Columns.Add("end", GetType(DateTime))
dt.Columns.Add("name", GetType(String))
dt.Columns.Add("id", GetType(String))

Dim dr As Data.DataRow = dt.NewRow()
dr("id") = 0
dr("start") = Convert.ToDateTime("15:50")
dr("end") = Convert.ToDateTime("15:55")
dr("name") = "Event 1"
dt.Rows.Add(dr)

dr = dt.NewRow()
dr("id") = 1
dr("start") = Convert.ToDateTime("16:00")
dr("end") = Convert.ToDateTime("17:00")
dr("name") = "Event 2"
dt.Rows.Add(dr)

dr = dt.NewRow()
dr("id") = 2
dr("start") = Convert.ToDateTime("16:15")
dr("end") = Convert.ToDateTime("18:45")
dr("name") = "Event 3"
dt.Rows.Add(dr)

Return dt
End Function
End Class

(这是我现在的 Web.Config 页面)

    <using System.Web.Configuration;  />
    <?xml version="1.0" encoding="utf-8"?>
    <!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
    <configuration>
    <connectionStrings>
    <add name="ConnStringDb1" connectionString="DataSource=Win08-SDBX1\SQLExpress;Initial Catalog=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient" />
    </connectionStrings>
    <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.5">
      <assemblies>
        <add assembly="Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.VisualC, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.VisualStudio.Tools.Applications.Adapter.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.VisualStudio.Tools.Applications.DesignTime.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.VisualStudio.Tools.Applications.Hosting.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.VisualStudio.Tools.Applications.ProgrammingModel, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5" />
    <pages>
      <controls>
        <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit"  namespace="AjaxControlToolkit" />
      </controls>
     </pages>
    </system.web>
    </configuration>

如果其中任何一个有意义,或者您看到我哪里出错了,请分享或更正我的编码。谢谢!

4

2 回答 2

0
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DayPilotCalendar1.DataSource = getData()
DataBind()
End Sub

This need to be 

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DayPilotCalendar1.DataSource = getData()
DayPilotCalendar1.DataBind()
End Sub
于 2013-09-05T20:42:39.653 回答
0

我们能看到 PageLoad 调用的 Databind 函数吗?

我在处理 C# asp.net 应用程序时遇到了类似的问题。我创建了一种方法来绑定包含卡片表的数据集中的数据。加载表时抛出“NullReferenceException 未被用户代码处理”,并且在查看表时我可以看到正在保存一个空值。

当您在调试并抛出异常时,数据表的保存值显示的是什么?

如果它为空,那么您的表不是指一个对象。

于 2013-12-12T16:33:52.783 回答