Click here to Skip to main content
15,883,705 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: HTTP Error 500.19 - Internal Server Error - The requested page cannot be accessed because the related configuration data for the page is invalid Pin
Richard Deeming30-Jan-20 1:06
mveRichard Deeming30-Jan-20 1:06 
GeneralRe: HTTP Error 500.19 - Internal Server Error - The requested page cannot be accessed because the related configuration data for the page is invalid Pin
simpledeveloper30-Jan-20 14:28
simpledeveloper30-Jan-20 14:28 
Question(SOLVED) Any ideas why gridview is not getting populated with data from the database? Pin
samflex29-Jan-20 9:30
samflex29-Jan-20 9:30 
SuggestionRe: Any ideas why gridview is not getting populated with data from the database? Pin
Richard Deeming30-Jan-20 1:02
mveRichard Deeming30-Jan-20 1:02 
GeneralRe: Any ideas why gridview is not getting populated with data from the database? Pin
samflex30-Jan-20 3:58
samflex30-Jan-20 3:58 
GeneralRe: Any ideas why gridview is not getting populated with data from the database? Pin
Richard Deeming30-Jan-20 4:05
mveRichard Deeming30-Jan-20 4:05 
GeneralRe: Any ideas why gridview is not getting populated with data from the database? Pin
samflex30-Jan-20 4:20
samflex30-Jan-20 4:20 
GeneralRe: Any ideas why gridview is not getting populated with data from the database? Pin
Richard Deeming30-Jan-20 4:53
mveRichard Deeming30-Jan-20 4:53 
You're only calling the fillSourceRecords method if the first row returned from the ValidateEmpID procedure was created last year.

I suspect you might have the previousYear / currentYear test the wrong way round - it doesn't make sense to me that you'd be able to edit last year's records, but not this year's records. But I don't know your requirements, so perhaps that's correct?

It looks like your ValidateEmpID procedure could return multiple rows, but you're only processing one row here. Again, that seems odd to me.

It looks like you want to clear the controls in all cases where the procedure doesn't return a row for either this year or the previous year. I'd be inclined to do that before executing the query; otherwise, you'll need to repeat the code in every Else block.

You'll probably want to remove the Thread.Sleep calls too, unless you're looking for an easy way to speed up the code in a future update. Smile | :)

I think something like this would possibly be easier to follow (assuming I've not missed something):
VB.NET
Protected Sub txtEmpID_TextChanged(sender As Object, e As EventArgs) Handles txtEmpID.TextChanged
    If String.IsNullOrEmpty(txtEmpID.Text) Then
        checkusername.Visible = False
        Return
    End If
    
    ' Clear the controls:
    txteName.Text = String.Empty
    txttitle.Text = String.Empty
    txtemail.Text = String.Empty
    lblStatus.Text = String.Empty
    
    Gridview1.DataSource = Nothing
    Gridview1.DataBind()
    
    checkusername.Visible = True
    dprocessed.Visible = True
    lblStatus.ForeColor = System.Drawing.Color.Red
    
    Using Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ConnectionString)
        Using cmd As New SqlCommand("ValidateEmpID", Conn)
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.AddWithValue("@empID", txtEmpID.Text)
            
            Conn.Open()
            Using dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
                If Not dr.Read() Then
                    imgstatus.ImageUrl = "images/Icon_Available.gif"
                    lblStatus.Text = "Proceed to complete entire form"
                    txteName.Enabled = True
                    txttitle.Enabled = True
                    txtemail.Enabled = True
                    txtEmpID.Enabled = True
                    GridPanels.Enabled = True
                    btnNext.Enabled = True
                    Return
                End If
                
                imgstatus.ImageUrl = "images/NotAvailable.jpg"
                txteName.Text = dr("employeeName").ToString()
                txttitle.Text = dr("empTitle").ToString()
                txtemail.Text = dr("email").ToString()
                txtEmpID.Text = dr("empID").ToString()
                
                If dr("previousYear").ToString() = "1" Then
                    lblStatus.Text = "Please verify your information for accuracy. Then complete rest of the form."
                    txteName.Enabled = True
                    txttitle.Enabled = True
                    txtemail.Enabled = True
                    txtEmpID.Enabled = True
                    GridPanels.Enabled = True
                    btnNext.Enabled = True
                    fillSourceRecords()
                
                Else If dr("thisYear").ToString() = "1" Then
                    lblStatus.Text = "You have already completed this Disclosure form. Please close the form. If you feel there is a mistake, please contact Clerk to the CEO and BOC at 404-371-3224"
                    txteName.Enabled = False
                    txttitle.Enabled = False
                    txtemail.Enabled = False
                    txtEmpID.Enabled = False
                    GridPanels.Enabled = False
                    btnNext.Enabled = False

                Else 
                    ' Not this year, nor the previous year
                    txteName.Enabled = False
                    txttitle.Enabled = False
                    txtemail.Enabled = False
                    txtEmpID.Enabled = False
                    GridPanels.Enabled = False
                    btnNext.Enabled = False
                End If
            End Using
        End Using
    End Using
End Sub




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


modified 30-Jan-20 13:09pm.

GeneralRe: Any ideas why gridview is not getting populated with data from the database? Pin
samflex30-Jan-20 5:14
samflex30-Jan-20 5:14 
GeneralRe: Any ideas why gridview is not getting populated with data from the database? Pin
samflex30-Jan-20 5:41
samflex30-Jan-20 5:41 
GeneralRe: Any ideas why gridview is not getting populated with data from the database? Pin
Richard Deeming30-Jan-20 5:47
mveRichard Deeming30-Jan-20 5:47 
GeneralRe: Any ideas why gridview is not getting populated with data from the database? Pin
samflex30-Jan-20 6:45
samflex30-Jan-20 6:45 
GeneralRe: Any ideas why gridview is not getting populated with data from the database? Pin
Richard Deeming30-Jan-20 7:08
mveRichard Deeming30-Jan-20 7:08 
GeneralRe: Any ideas why gridview is not getting populated with data from the database? Pin
samflex30-Jan-20 8:11
samflex30-Jan-20 8:11 
QuestionWriting a client app for OData Pin
simpledeveloper29-Jan-20 7:13
simpledeveloper29-Jan-20 7:13 
QuestionDropdown Filtering in grideview vb.net Pin
Member 315525329-Jan-20 4:16
Member 315525329-Jan-20 4:16 
QuestionFiles download fails for ipad and iphone clients Pin
alesanndro28-Jan-20 20:34
alesanndro28-Jan-20 20:34 
AnswerRe: Files download fails for ipad and iphone clients Pin
Nathan Minier29-Jan-20 5:42
professionalNathan Minier29-Jan-20 5:42 
GeneralRe: Files download fails for ipad and iphone clients Pin
alesanndro29-Jan-20 6:51
alesanndro29-Jan-20 6:51 
GeneralRe: Files download fails for ipad and iphone clients Pin
Nathan Minier29-Jan-20 9:28
professionalNathan Minier29-Jan-20 9:28 
GeneralRe: Files download fails for ipad and iphone clients Pin
alesanndro30-Jan-20 1:24
alesanndro30-Jan-20 1:24 
GeneralRe: Files download fails for ipad and iphone clients Pin
Nathan Minier30-Jan-20 6:01
professionalNathan Minier30-Jan-20 6:01 
QuestionProcedure or function 'bla' expects parameter '@OrderNumber', which was not supplied. Pin
Johan Hakkesteegt27-Jan-20 21:50
Johan Hakkesteegt27-Jan-20 21:50 
AnswerRe: Procedure or function 'bla' expects parameter '@OrderNumber', which was not supplied. Pin
F-ES Sitecore27-Jan-20 23:20
professionalF-ES Sitecore27-Jan-20 23:20 
GeneralRe: Procedure or function 'bla' expects parameter '@OrderNumber', which was not supplied. Pin
Johan Hakkesteegt27-Jan-20 23:50
Johan Hakkesteegt27-Jan-20 23:50 

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.