1 Replies - 1449 Views - Last Post: 14 September 2009 - 09:00 AM Rate Topic: -----

#1 JynxRD  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 78
  • Joined: 06-November 08

Help with a dataview grid

Posted 13 September 2009 - 08:30 AM

I'm not sure what all is needed but this is the code behind the design view for this page. Basically it works however when I start up the page instead of the dataview grid being empty until I run a customer ID, it instead shows the numbers 27,28,29 through 43. Then when I run my customerID number it still shows those numbers yet it also shows what it is supposed to below those numbers. I can't figure out where in the world these numbers are coming from when I run the page.

Imports System.Data

Partial Class CustomerSurvey
    Inherits System.Web.UI.Page

    Dim dvTable As DataView

    Protected Sub btnGetIncidents_Click(ByVal sender As Object, _
            ByVal e As System.EventArgs) Handles btnGetIncidents.Click
        dvTable = CType(AccessDataSource1.Select( _
            DataSourceSelectArguments.Empty), DataView)
        dvTable.RowFilter = "CustomerID = " & txtCustomerID.Text _
            & " And DateClosed Is Not Null"
        If dvTable.Count > 0 Then
            EnableControls(True) '
            lblNoIncidents.Text = "There are no incidents for that customer."
        End If
    End Sub

    Private Sub DisplayClosedIncidents()
        lstIncidents.Items.Add(New ListItem("--Select an incident--", "None"))
        For Each drvRow As DataRowView In dvTable
            Dim incident As New Incident
            incident.IncidentID = CInt(drvRow("IncidentID"))
            incident.ProductCode = drvRow("ProductCode").ToString
            incident.DateClosed = CDate(drvRow("DateClosed"))
            incident.Title = drvRow("Title").ToString
            lstIncidents.Items.Add(New ListItem( _
            incident.CustomerIncidentDisplay, incident.IncidentID))
        lstIncidents.SelectedIndex = 0
        lblNoIncidents.Text = ""
    End Sub

    Private Sub EnableControls(ByVal enable As Boolean)
        lstIncidents.Enabled = enable
        lblHeading.Enabled = enable
        lblResponseTime.Enabled = enable
        rblResponseTime.Enabled = enable
        lblEfficiency.Enabled = enable
        rblEfficiency.Enabled = enable
        lblResolution.Enabled = enable
        rblResolution.Enabled = enable
        lblComments.Enabled = enable
        txtComments.Enabled = enable
        chkContact.Enabled = enable
        rdoContactByEmail.Enabled = enable
        rdoContactByPhone.Enabled = enable
        btnSubmit.Enabled = enable
    End Sub

    Protected Sub btnSubmit_Click(ByVal sender As Object, _
            ByVal e As System.EventArgs) Handles btnSubmit.Click
        If Page.IsValid Then
            Dim survey As New Survey
            survey.CustomerID = txtCustomerID.Text
            survey.IncidentID = lstIncidents.SelectedValue
            If rblResponseTime.SelectedIndex <> -1 Then
                survey.ResponseTime = rblResponseTime.SelectedValue
            End If
            If rblEfficiency.SelectedIndex <> -1 Then
                survey.TechEfficiency = rblEfficiency.SelectedValue
            End If
            If rblresolution.SelectedIndex <> -1 Then
                survey.Resolution = rblresolution.SelectedValue
            End If
            survey.Comments = txtComments.Text
            If chkContact.Checked Then
                survey.Contact = True
                If rdoContactByEmail.Checked Then
                    survey.ContactBy = "Email"
                    survey.ContactBy = "Phone"
                End If
                Session.Add("Contact", True)
                survey.Contact = False
                Session.Add("Contact", False)
            End If
            'REDIRECT TO THE WEB PAGE SurveyComplete.aspx
        End If
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub
End Class

Is This A Good Question/Topic? 0
  • +

Replies To: Help with a dataview grid

#2 woodjom  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 34
  • View blog
  • Posts: 566
  • Joined: 08-May 08

Re: Help with a dataview grid

Posted 14 September 2009 - 09:00 AM

If i had to guess, you are autofilling the grid....also, what are "27,28,29 through 43"? Sounds like those are page numbers. I would suggest attaching your Databinding operation to the "btnGetIncidents_Click" event, since it seems you want to fill the Grid once you input the customerID.

What i do is setup the Gridview columns only and then in my code pending on where i want the GV to populate, i then associate the respective BLL class to the Gridview. I am currently working on getting it to where i just simply place the Gridview and setup the columsn through the same BLL class so that way i just have to drag, drop, and maybe place the control on the page only.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1