Click here to Skip to main content
15,917,731 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: increment video path files Pin
Eddy Vluggen17-Feb-17 4:14
professionalEddy Vluggen17-Feb-17 4:14 
Questioni need one live chat session code for asp.net website.... Pin
Member 1294241913-Feb-17 19:17
Member 1294241913-Feb-17 19:17 
AnswerRe: i need one live chat session code for asp.net website.... Pin
Nelek13-Feb-17 19:20
protectorNelek13-Feb-17 19:20 
AnswerRe: i need one live chat session code for asp.net website.... Pin
F-ES Sitecore14-Feb-17 2:41
professionalF-ES Sitecore14-Feb-17 2:41 
AnswerRe: i need one live chat session code for asp.net website.... Pin
ZurdoDev14-Feb-17 3:19
professionalZurdoDev14-Feb-17 3:19 
QuestionASP.Net Classic Web Application Problem Pin
Zeyad Jalil10-Feb-17 22:08
professionalZeyad Jalil10-Feb-17 22:08 
QuestionCan AngularJS use only with MVC or we can use it with Asp.Net application. Pin
Abhijit Mindcraft5-Feb-17 21:56
Abhijit Mindcraft5-Feb-17 21:56 
AnswerRe: Can AngularJS use only with MVC or we can use it with Asp.Net application. Pin
Richard MacCutchan5-Feb-17 22:18
mveRichard MacCutchan5-Feb-17 22:18 
GeneralRe: Can AngularJS use only with MVC or we can use it with Asp.Net application. Pin
Abhijit Mindcraft5-Feb-17 22:31
Abhijit Mindcraft5-Feb-17 22:31 
GeneralRe: Can AngularJS use only with MVC or we can use it with Asp.Net application. Pin
Richard MacCutchan5-Feb-17 23:19
mveRichard MacCutchan5-Feb-17 23:19 
AnswerRe: Can AngularJS use only with MVC or we can use it with Asp.Net application. Pin
Nathan Minier6-Feb-17 1:41
professionalNathan Minier6-Feb-17 1:41 
GeneralRe: Can AngularJS use only with MVC or we can use it with Asp.Net application. Pin
Abhijit Mindcraft6-Feb-17 1:53
Abhijit Mindcraft6-Feb-17 1:53 
GeneralRe: Can AngularJS use only with MVC or we can use it with Asp.Net application. Pin
Nathan Minier6-Feb-17 1:58
professionalNathan Minier6-Feb-17 1:58 
QuestionDisplay message to the user if no records found? Pin
samflex30-Jan-17 8:14
samflex30-Jan-17 8:14 
AnswerRe: Display message to the user if no records found? Pin
ZurdoDev30-Jan-17 8:33
professionalZurdoDev30-Jan-17 8:33 
AnswerRe: Display message to the user if no records found? Pin
Richard Deeming30-Jan-17 8:41
mveRichard Deeming30-Jan-17 8:41 
The only time you're displaying the message is if the reportType is not set to either "Today", "Yesterday" or "All". If it's one of those values, but there are no matching records, you don't display the message.

As an aside, it looks like you're storing the date in a varchar column. That's an extremely bad idea. You should use one of the date/time types[^] provided by SQL.
VB.NET
Using con As New SqlConnection("...")
    Using cmd As New SqlCommand("", con)
        Dim reportType As String = ddlrpttype.SelectedValue
        If reportType = "Today" Then
            cmd.CommandText = "SELECT * FROM mytble WHERE work_request_date >= @MinDate And work_request_date < @MaxDate"
            cmd.Parameters.AddWithValue("@MinDate", DateTime.Today)
            cmd.Parameters.AddWithValue("@MaxDate", DateTime.Today.AddDays(1))
            
        ElseIf reportType = "Yesterday" Then
            cmd.CommandText = "SELECT * FROM mytble WHERE work_request_date >= @MinDate And work_request_date < @MaxDate"
            cmd.Parameters.AddWithValue("@MinDate", DateTime.Today.AddDays(-1))
            cmd.Parameters.AddWithValue("@MaxDate", DateTime.Today)
            
        Else
            cmd.CommandText = "SELECT * FROM mytble"
        End If
        
        Using dr As SqlDataReader = cmd.ExecuteReader()
            reportgrv.DataSource = dr
            reportgrv.DataBind()
        End Using
    End Using
End Using

If reportgrv.Rows.Count = 0 Then
    lblmsg.Text = "No matching records found."
Else
    lblmsg.Text = Nothing
End If

As an alternative to manually updating the label, you could use either the EmptyDataTemplate[^] or EmptyDataText[^] properties on the GridView to display a message when there are no rows to display.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Display message to the user if no records found? Pin
samflex31-Jan-17 5:26
samflex31-Jan-17 5:26 
GeneralRe: Display message to the user if no records found? Pin
ZurdoDev3-Feb-17 3:26
professionalZurdoDev3-Feb-17 3:26 
QuestionStrange behaviour .net 2/4: The object of type "System.Web.UI.WebControls.Label" can not be converted to type "System.Web.UI.WebControls.TextBox". Pin
Markus Evacoso25-Jan-17 11:24
Markus Evacoso25-Jan-17 11:24 
SuggestionRe: Strange behaviour .net 2/4: The object of type "System.Web.UI.WebControls.Label" can not be converted to type "System.Web.UI.WebControls.TextBox". Pin
ZurdoDev26-Jan-17 0:54
professionalZurdoDev26-Jan-17 0:54 
GeneralRe: Strange behaviour .net 2/4: The object of type "System.Web.UI.WebControls.Label" can not be converted to type "System.Web.UI.WebControls.TextBox". Pin
Markus Evacoso26-Jan-17 20:56
Markus Evacoso26-Jan-17 20:56 
AnswerRe: Strange behaviour .net 2/4: The object of type "System.Web.UI.WebControls.Label" can not be converted to type "System.Web.UI.WebControls.TextBox". Pin
F-ES Sitecore26-Jan-17 22:37
professionalF-ES Sitecore26-Jan-17 22:37 
GeneralRe: Strange behaviour .net 2/4: The object of type "System.Web.UI.WebControls.Label" can not be converted to type "System.Web.UI.WebControls.TextBox". Pin
Markus Evacoso22-Jun-17 23:44
Markus Evacoso22-Jun-17 23:44 
Question<Projectname>.config in bin folder Pin
Markus Evacoso25-Jan-17 10:55
Markus Evacoso25-Jan-17 10:55 
AnswerRe: <Projectname>.config in bin folder Pin
ZurdoDev26-Jan-17 0:51
professionalZurdoDev26-Jan-17 0:51 

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.