我正在使用Visual Studio! (telerik就像gridview,同样的东西) 我想慢慢地试图用ASP创建一个调度程序:Repeater !!! 有人请救我脱离这种永无止境的折磨!洛尔
目标:这是患者预约的页面!因此,该页面有一个网格,显示文档的信息及其可用性(TimeSlot)! [请参阅附图]
---。ASPX ---- 下面是ASPX代码(正面)
<telerik:RadGrid ID="RadGrid_provider_details" runat="server" DataSourceID="SDS_provider_detail"
Height="700px" Skin="Metro" Width="100%" PageSize="3" AutoGenerateColumns="false">
<GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
<MasterTableView DataSourceID="SDS_provider_detail" Font-Size="Large" DataKeyNames="provider_code">
<NoRecordsTemplate>
There is no result with the selected filter.
</NoRecordsTemplate>
<Columns>
<telerik:GridBoundColumn DataField="providerFullName" HeaderStyle-Width="15%" ItemStyle-Height="200px"
HeaderText="Name" ReadOnly="True" SortExpression="providerFullName" UniqueName="providerFullName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="taxonomy_desc" HeaderText="Specialty" ReadOnly="True"
SortExpression="taxonomy_desc" HeaderStyle-Width="15%">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="addr1" HeaderText="Address" ReadOnly="True" SortExpression="addr1"
HeaderStyle-Width="15%">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:Repeater ID="Repeater_appt" runat="server" DataSourceID="SDS_Repeater_appt">
<ItemTemplate>
<%--<asp:Label runat="server" ID="lbl_appt" Text="YEAH"></asp:Label>--%>
<asp:Button runat="server" ID="btn_haha" Text='<%# Eval("timeslot") %>' Font-Size="Large"
Width="100px" />
</ItemTemplate>
</asp:Repeater>
<asp:Button runat="server" ID="btn_more_appt" Text="More" Font-Size="Large" Width="100px" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
<ItemStyle CssClass="item-style" />
<AlternatingItemStyle CssClass="item-style" />
</MasterTableView>
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" ScrollHeight="650px"></Scrolling>
</ClientSettings>
</telerik:RadGrid>
<asp:SqlDataSource ID="SDS_Repeater_appt" runat="server"></asp:SqlDataSource>
<asp:SqlDataSource ID="SDS_provider_detail" runat="server">
<SelectParameters>
</SelectParameters>
</asp:SqlDataSource>
---。VB -----
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports Telerik.Web.UI
Partial Class Appointment
Inherits System.Web.UI.Page
Protected Sub RadGrid_provider_details_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid_provider_details.ItemDataBound
'This sub gets activated so I can get the provider-code for the providers...I don't get it too well
'The provider code is required to get the availability for the doctors, and it is from the datasource of the grid
'Here is also where I call the BindRepeater_retrieveTimeSlotAvailbility() '
If TypeOf e.Item Is GridDataItem Then
Dim item As GridDataItem = TryCast(e.Item, GridDataItem)
Dim provider_code As String = item.GetDataKeyValue("provider_code").ToString()
Dim item2 As GridDataItem = DirectCast(e.Item, GridDataItem)
Dim Repeater_appt As Repeater = DirectCast(item2.FindControl("Repeater_appt"), Repeater)
BindRepeater_retrieveTimeSlotAvailbility(provider_code, Repeater_appt)
End If
End Sub
Private Sub BindRepeater_retrieveTimeSlotAvailbility(ByVal provider_code As String, ByRef Repeater_appt As Repeater)
initializeScheduler()
Dim SQlstr As String, RtnStr As String
Dim selected_org_code As String = ""
selected_org_code = DDL_Clinic.SelectedValue
HF_OrgCode.Value = selected_org_code
Dim connectionStr As String = ""
connectionStr = GetClientConnectionStringByOrgCode(selected_org_code)
Dim errormsg As String = ""
SQlstr = "select office_location from locations where facility_name= '" & DDL_Clinic.SelectedItem.Text & "'"
Dim office_location As String = PubFunc.SelectOneBySQL2(SQlstr, connectionStr, errormsg)
If errormsg <> "" Then
MessageDisplayInModal(errormsg, True)
End If
If provider_code <> "" Then
Dim In_String As String = "'0',"
In_String &= "'" & provider_code & "'," & "'0'"
'===========================
Dim dateToSchedule As DateTime
dateToSchedule = txt_DateToSchedule.Text
dateToSchedule.ToShortDateString()
time_slot_SQL2(SQlstr, dateToSchedule.ToShortDateString(), office_location, RtnStr, In_String, day_start, day_end)
''Added by HELPER, but I didn't get it.. it gives me a 'Both datasource and datasourceID are defined on 'Repeater_appt' Remove one definition' error
'Execute SQlstr and get datatable.
'Datatable dt = Result of SQlstr
'Repeater_appt.DataSource = SQlstr
'Repeater_appt.DataBind()
SDS_Repeater_appt.SelectCommand = SQlstr
SDS_Repeater_appt.ConnectionString = connectionStr
SDS_Repeater_appt.DataBind()
End If
Protected Sub time_slot_SQL2(ByRef SQLStr As String, ByVal dateToSchedule As String, ByVal office_location As String, ByVal RtnStr As String, ByVal In_String As String, ByVal day_start As String, ByVal day_end As String)
'The original sql is super long, basically, just return the SQLstr (byRef) to where it calls it! (just to make code neater)
SQLStr = "SELECT TOP 5 timeslot from appt where provider_code = '100'"
End Sub
End Class
&#39;运行代码时发生的事情的结果: 测试数据:假设有3个测试提供者(provider1,provider2,provider3;他们都有diff TIMESLOT)
代码运行:
提前致谢!!!!!!