Click here to Skip to main content
14,665,866 members
Home » Discussions » ASP.NET
   

ASP.NET

 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Mou_kol21-Feb-20 22:40
MemberMou_kol21-Feb-20 22:40 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Bohdan Stupak23-Feb-20 0:19
professionalBohdan Stupak23-Feb-20 0:19 
GeneralRe: ASP.Net MVC: When to use HttpGet and when to use HttpPost for action Pin
Richard Deeming23-Feb-20 21:16
mveRichard Deeming23-Feb-20 21:16 
QuestionUpdating two related tables in asp.net core Pin
ElenaRez16-Feb-20 18:35
MemberElenaRez16-Feb-20 18:35 
QuestionBinding combox in gridview with selected value of another comboBox Pin
BikerMonkey14-Feb-20 9:01
professionalBikerMonkey14-Feb-20 9:01 
QuestionHow to get a field's value from a linq query Pin
ElenaRez12-Feb-20 3:09
MemberElenaRez12-Feb-20 3:09 
AnswerRe: How to get a field's value from a linq query Pin
Richard Deeming12-Feb-20 4:45
mveRichard Deeming12-Feb-20 4:45 
QuestionStill having some display problems Pin
samflex7-Feb-20 5:36
Membersamflex7-Feb-20 5:36 
Greetings again,

This is part of the solution that the great Richard provided last week.

The app takes empID and determines if the employee has ever completed the form before.

If this is the first time the employee is compleing the form, then the form is completely blank so employee can complete entire form.

This works great.

It also checks to see if the employee had completed the form before, if yes but not the previous year, then employee name, title, email and employee ID are loaded but the rest of the form is blank so the user can complete the rest of the form.

This also works great.

Here is the part that we are still having problem with.

An employee can complete one gridview control, say GridView1, add an additional row and complete that row.

In this situation, if the employee completed form the previous year, then when the data that the employee had completed the previous year is loaded, it displays the two rows that employee completed for GridView1.

The problem is that all other gridview controls like grvspouse, grvspouse, etc for instance, are are also loaded with two rows even though those rows are blank.

Is there somethin I can change in the attached code that will ensure that those gridview controls like the two examples I showed above, show just one row since they have not been completed before?

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:
      'txtEmpID.Text = String.Empty
      txteName.Text = String.Empty
      txttitle.Text = String.Empty
      txtemail.Text = String.Empty
      lblStatus.Text = String.Empty

      Gridview1.DataSource = Nothing
      Gridview1.DataBind()
      grvspouse.DataSource = Nothing
      grvspouse.DataBind()
      grvDiv.DataSource = Nothing
      grvDiv.DataBind()
      grvReim.DataSource = Nothing
      grvReim.DataBind()
      grvHon.DataSource = Nothing
      grvHon.DataBind()
      grvGift.DataSource = Nothing
      grvGift.DataBind()
      grvOrg.DataSource = Nothing
      grvOrg.DataBind()
      grvCred.DataSource = Nothing
      grvCred.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 = "This must be the first time you are completing this form. Proceed to complete entire form. If you feel there is a mistake, please contact the office"
                      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()

                  ElseIf dr("thisYear").ToString() = "1" Then
                      lblStatus.Text = "You have already completed this form. Please close the form. If you feel there is a mistake, please contact the office"
                      txteName.Enabled = False
                      txttitle.Enabled = False
                      txtemail.Enabled = False
                      txtEmpID.Enabled = False
                      GridPanels.Enabled = False
                      btnNext.Enabled = False

                  Else
                      lblStatus.Text = "No entries this year, nor the previous year. Please complete the form. If you feel this 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
                  End If
              End Using
          End Using
      End Using
  End Sub

  Private Sub fillSourceRecords()
      Dim conn_str As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString

      Using conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ConnectionString)
          conn.Open()
          Using sourcecmd As SqlCommand = New SqlCommand()
              sourcecmd.CommandText = "uspGetAllRecs"
              sourcecmd.CommandType = CommandType.StoredProcedure
              sourcecmd.Parameters.AddWithValue("@empID", txtEmpID.Text.Trim())
              sourcecmd.Connection = conn
              Using ad As SqlDataAdapter = New SqlDataAdapter(sourcecmd)
                  Dim ds As DataSet = New DataSet()
                  ad.Fill(ds)
                  Gridview1.DataSource = ds
                  Gridview1.DataBind()
                  grvspouse.DataSource = ds
                  grvspouse.DataBind()
                  grvDiv.DataSource = ds
                  grvDiv.DataBind()
                  grvReim.DataSource = ds
                  grvReim.DataBind()
                  grvHon.DataSource = ds
                  grvHon.DataBind()
                  grvGift.DataSource = ds
                  grvGift.DataBind()
                  grvOrg.DataSource = ds
                  grvOrg.DataBind()
                  grvCred.DataSource = ds
                  grvCred.DataBind()
              End Using
          End Using
      End Using

  End Sub

QuestionHow to set starting page or controller method of a web application when we are deploying the React or Angular or Ember applications Pin
simpledeveloper6-Feb-20 14:35
Membersimpledeveloper6-Feb-20 14:35 
AnswerRe: How to set starting page or controller method of a web application when we are deploying the React or Angular or Ember applications Pin
jkirkerx7-Feb-20 10:01
professionaljkirkerx7-Feb-20 10:01 
GeneralRe: How to set starting page or controller method of a web application when we are deploying the React or Angular or Ember applications Pin
simpledeveloper7-Feb-20 12:50
Membersimpledeveloper7-Feb-20 12:50 
QuestionHow do I solve InvalidCaseUserControl.Dispose(bool) no suitable method found to override Pin
Member 114033043-Feb-20 7:36
MemberMember 114033043-Feb-20 7:36 
AnswerRe: How do I solve InvalidCaseUserControl.Dispose(bool) no suitable method found to override Pin
Richard Deeming3-Feb-20 7:46
mveRichard Deeming3-Feb-20 7:46 
GeneralRe: How do I solve InvalidCaseUserControl.Dispose(bool) no suitable method found to override Pin
Member 114033043-Feb-20 8:11
MemberMember 114033043-Feb-20 8:11 
QuestionIn need of direction for project Pin
led3-Feb-20 7:31
Memberled3-Feb-20 7:31 
AnswerRe: In need of direction for project Pin
phil.o3-Feb-20 23:14
mvephil.o3-Feb-20 23:14 
GeneralRe: In need of direction for project Pin
led4-Feb-20 6:21
Memberled4-Feb-20 6:21 
GeneralRe: In need of direction for project Pin
phil.o4-Feb-20 6:38
mvephil.o4-Feb-20 6:38 
Question.net core Swagger code gen Pin
manoj62931-Jan-20 14:28
Membermanoj62931-Jan-20 14:28 
QuestionIIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site Pin
holdorf31-Jan-20 5:30
Memberholdorf31-Jan-20 5:30 
AnswerRe: IIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site Pin
Richard Deeming31-Jan-20 5:49
mveRichard Deeming31-Jan-20 5:49 
GeneralRe: IIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site Pin
holdorf31-Jan-20 6:51
Memberholdorf31-Jan-20 6:51 
GeneralRe: IIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site Pin
Richard Deeming31-Jan-20 7:13
mveRichard Deeming31-Jan-20 7:13 
GeneralRe: IIS changing the IE11 document mode from 11 (Default) to 7 (Default) when browsing to a site Pin
holdorf31-Jan-20 7:50
Memberholdorf31-Jan-20 7:50 
QuestionSQL and IIS error when publish an ASP .NET application to IIS Pin
holdorf30-Jan-20 12:54
Memberholdorf30-Jan-20 12:54 

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.