Click here to Skip to main content
15,888,062 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: how to enable false of iframe page in asp.net not display false by jquery and css? Pin
ZurdoDev15-Aug-14 5:28
professionalZurdoDev15-Aug-14 5:28 
QuestionRequiredfield validator is not working Pin
murali_utr14-Aug-14 18:47
murali_utr14-Aug-14 18:47 
AnswerRe: Requiredfield validator is not working Pin
ZurdoDev15-Aug-14 5:29
professionalZurdoDev15-Aug-14 5:29 
QuestionHow to display certain records if user's search comes up empty? Pin
samflex14-Aug-14 6:20
samflex14-Aug-14 6:20 
SuggestionRe: How to display certain records if user's search comes up empty? Pin
Richard Deeming14-Aug-14 6:45
mveRichard Deeming14-Aug-14 6:45 
GeneralRe: How to display certain records if user's search comes up empty? Pin
samflex14-Aug-14 7:01
samflex14-Aug-14 7:01 
GeneralRe: How to display certain records if user's search comes up empty? Pin
Richard Deeming14-Aug-14 7:28
mveRichard Deeming14-Aug-14 7:28 
GeneralRe: How to display certain records if user's search comes up empty? Pin
samflex14-Aug-14 17:07
samflex14-Aug-14 17:07 
Hi Richard,

Thank you very much sir.

Your code is so elegant. I hope to get close to where you are one day.

I have pretty much put all the pieces together but I think I have things a bit mixed up because first, I commented out some lines that are throwing errors.

Second, when the page loads, I start paging, it starts showing some weird lines.

Can you see what I am doing wrong?

PHP
Private Sub showGrid()

    Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("conString").ConnectionString)
    ' Dim strQuery As String

    Dim cmd As New SqlCommand("-placeholder-", conn)
    Dim sb As New StringBuilder("SELECT L.LocationId," & _
           "c.courseId, " & _
            "c.coursename, " & _
           "CASE WHEN L.Seating_Capacity - COALESCE(TS.TakenSeats,0) = 0 THEN 'Not Available' " & _
               " ELSE 'Available' END AS 'AvailableSeats'," & _
            "d.dateid, " & _
           " d.trainingDates, " & _
            "d.trainingtime, " & _
           " c.CourseDescription, " & _
           " i.instructorName, " & _
            "l.location " & _
          " FROM tblLocations L " & _
          " Inner Join tblCourses c on l.locationId = c.locationId " & _
          " Inner Join tblTrainingDates d on c.dateid=d.dateid " & _
         "  Inner Join tblCourseInstructor ic on c.courseId = ic.CourseId " & _
         "  Inner Join tblInstructors i on ic.instructorId = i.instructorId " & _
         "  OUTER APPLY (Select Count(*) TakenSeats " & _
         "  FROM tblTrainings T " & _
         "  where(L.LocationId = T.LocationId) " & _
         "  AND c.courseId = t.courseId) TS")

    ' Hard-code the acceptable values here:
    Dim andors As String = If(ANDOR.SelectedValue = "OR", " OR ", " AND ")
    Dim startedWhere As Boolean = False

    If DropDownList1.SelectedValue <> "" Then
        sb.Append(If(startedWhere, andors, " WHERE "))
        sb.Append("i.instructorName = @InstructorName")
        cmd.Parameters.AddWithValue("@InstructorName", DropDownList1.SelectedValue)
        startedWhere = True
    End If

    If ViewSelect = "Range" Then
        sb.Append(If(startedWhere, andors, " WHERE "))
        sb.Append("d.trainingDates Between @FromDate And @EndDate")
        cmd.Parameters.AddWithValue("@FromDate", Date.Parse(txtFromDate.Text))
        cmd.Parameters.AddWithValue("@EndDate", Date.Parse(txtToDate.Text))
        startedWhere = True

    ElseIf ViewSelect = "Specific" Then
        sb.Append(If(startedWhere, andors, " WHERE "))
        sb.Append("d.trainingDates = @SpecificDate")
        cmd.Parameters.AddWithValue("@SpecificDate", Date.Parse(txtSpecificDate.Text))
        startedWhere = True
    End If

    cmd.CommandText = sb.ToString()

    ' Dim cmd As New SqlCommand(strQuery) 'This says cmd has already been declared
    Dim dt As DataTable = GetData(cmd)
    If dt.Rows.Count = 0 Then

        cmd.Parameters.Clear()
        cmd.Parameters.AddWithValue("@FromDate", Date.Today.AddMonths(-1))
        cmd.Parameters.AddWithValue("@EndDate", Date.Today)

        cmd.CommandText = "SELECT L.LocationId," & _
           "c.courseId, " & _
            "c.coursename, " & _
           "CASE WHEN L.Seating_Capacity - COALESCE(TS.TakenSeats,0) = 0 THEN 'Not Available' " & _
               " ELSE 'Available' END AS 'AvailableSeats'," & _
            "d.dateid, " & _
           " d.trainingDates, " & _
            "d.trainingtime, " & _
           " c.CourseDescription, " & _
           " i.instructorName, " & _
            "l.location " & _
          " FROM tblLocations L " & _
          " Inner Join tblCourses c on l.locationId = c.locationId " & _
          " Inner Join tblTrainingDates d on c.dateid=d.dateid " & _
         "  Inner Join tblCourseInstructor ic on c.courseId = ic.CourseId " & _
         "  Inner Join tblInstructors i on ic.instructorId = i.instructorId " & _
         "  OUTER APPLY (Select Count(*) TakenSeats " & _
         "  FROM tblTrainings T " & _
         "  where(L.LocationId = T.LocationId) " & _
         "  AND c.courseId = t.courseId) TS " & _
         " where d.trainingDates Between @FromDate And @EndDate"

        dt = GetData(cmd)
    End If

    GridView1.DataSource = dt
    GridView1.DataBind()

End Sub

GeneralRe: How to display certain records if user's search comes up empty? Pin
Richard Deeming18-Aug-14 2:02
mveRichard Deeming18-Aug-14 2:02 
GeneralRe: How to display certain records if user's search comes up empty? Pin
samflex18-Aug-14 2:54
samflex18-Aug-14 2:54 
GeneralRe: How to display certain records if user's search comes up empty? Pin
Richard Deeming18-Aug-14 7:15
mveRichard Deeming18-Aug-14 7:15 
GeneralRe: How to display certain records if user's search comes up empty? Pin
samflex18-Aug-14 8:04
samflex18-Aug-14 8:04 
GeneralRe: How to display certain records if user's search comes up empty? Pin
Richard Deeming18-Aug-14 8:38
mveRichard Deeming18-Aug-14 8:38 
GeneralRe: How to display certain records if user's search comes up empty? Pin
samflex18-Aug-14 10:55
samflex18-Aug-14 10:55 
QuestionAJAX control Pin
murali_utr13-Aug-14 23:09
murali_utr13-Aug-14 23:09 
GeneralRe: AJAX control Pin
Kornfeld Eliyahu Peter13-Aug-14 23:18
professionalKornfeld Eliyahu Peter13-Aug-14 23:18 
GeneralRe: AJAX control Pin
murali_utr14-Aug-14 18:00
murali_utr14-Aug-14 18:00 
QuestionGet original string from Guid Pin
Member 947380913-Aug-14 19:06
Member 947380913-Aug-14 19:06 
AnswerRe: Get original string from Guid Pin
Bernhard Hiller13-Aug-14 21:57
Bernhard Hiller13-Aug-14 21:57 
AnswerRe: Get original string from Guid Pin
Kornfeld Eliyahu Peter13-Aug-14 22:27
professionalKornfeld Eliyahu Peter13-Aug-14 22:27 
AnswerRe: Get original string from Guid Pin
Richard MacCutchan13-Aug-14 22:28
mveRichard MacCutchan13-Aug-14 22:28 
QuestionRe: Get original string from Guid Pin
Member 947380915-Aug-14 18:49
Member 947380915-Aug-14 18:49 
QuestionDynamic Linq Query in vb.net Pin
murali_utr12-Aug-14 18:51
murali_utr12-Aug-14 18:51 
AnswerRe: Dynamic Linq Query in vb.net Pin
Bernhard Hiller12-Aug-14 21:11
Bernhard Hiller12-Aug-14 21:11 
QuestionFetch data from database based checkboxlist selection getting error Pin
Venugopal626412-Aug-14 17:34
Venugopal626412-Aug-14 17:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.