0 Replies - 820 Views - Last Post: 12 July 2017 - 08:13 AM Rate Topic: -----

#1 biuechocoo   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 12-July 17


Posted 12 July 2017 - 08:13 AM

I am using Visual studio! (telerik is like gridview, same stuff)
I am like dying slowly trying to create a scheduler with ASP: Repeater!!!
Someone please save me from this never-ending torture! lol

GOAL: This is a page for patients to make appointments! So, the page has a grid that shows the doc's information along with their availability (TimeSlot)! [PLEASE refer to attached image]

Below is the ASPX code (front side)

<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">
                                There is no result with the selected filter.
                                <telerik:GridBoundColumn DataField="providerFullName" HeaderStyle-Width="15%" ItemStyle-Height="200px"
                                    HeaderText="Name" ReadOnly="True" SortExpression="providerFullName" UniqueName="providerFullName">
                                <telerik:GridBoundColumn DataField="taxonomy_desc" HeaderText="Specialty" ReadOnly="True"
                                    SortExpression="taxonomy_desc" HeaderStyle-Width="15%">
                                <telerik:GridBoundColumn DataField="addr1" HeaderText="Address" ReadOnly="True" SortExpression="addr1"
                                        <asp:Repeater ID="Repeater_appt" runat="server" DataSourceID="SDS_Repeater_appt">
                                                <%--<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" />
                                        <asp:Button runat="server" ID="btn_more_appt" Text="More" Font-Size="Large" Width="100px" />
                            <ItemStyle CssClass="item-style" />
                            <AlternatingItemStyle CssClass="item-style" />
                            <Scrolling AllowScroll="True" UseStaticHeaders="True" ScrollHeight="650px"></Scrolling>
                    <asp:SqlDataSource ID="SDS_Repeater_appt" runat="server"></asp:SqlDataSource>
                    <asp:SqlDataSource ID="SDS_provider_detail" runat="server">

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)

        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

            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

            SDS_Repeater_appt.SelectCommand = SQlstr
            SDS_Repeater_appt.ConnectionString = connectionStr
        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

'RESULT of what's happening when I run the codes:
Test Data: Suppose to have 3 test providers (provider1, provider2, provider3; they all have diff TIMESLOT)

Code run:
1. Calls RadGrid_provider_details_ItemDataBound once; e.item is NOT a GridDataItem, so it exit sub
2. Calls ItemDataBound again, e.item is a GridDataItem, get provider1’s providercode it goes through the code, and calls BindRepeater_retrieveTimeSlotAvailbility(provider_code, repeater_appt)
3. Calls ItemDataBound again, e.item is NOT a GridDataItem, so it exit sub
4. Goes to the front (aspx), and EVAL (timeslot) 5 times
5. Calls ItemDataBound again, e.item is a GridDataItem, provider2’s providercode2, and goes through
6. Calls ItemDataBound again, e.item is NOT a GridDataItem, so it exit sub
7. Goes back to the front (aspx) again, and runs 5 times
8. Calls ItemDataBound again, e.item is a GridDataItem, provider3’s providercode3, and goes through
9. Calls ItemDataBound again, e.item is NOT a GridDataItem, so it exit sub
10. Calls ItemDataBound again, e.item is NOT a GridDataItem, so it exit sub
11. RadGrid_provider_detail.databind()
12. Goes back to the front (aspx) again, and runs 15 times and done…

Thanks in advance!!!!!!

This post has been edited by modi123_1: 12 July 2017 - 08:16 AM
Reason for edit:: In the future please use the [code] tag button in the editor.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1