2 Replies - 915 Views - Last Post: 03 May 2019 - 11:58 AM Rate Topic: -----

#1 cpilawski   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 21-June 15

Data Repeater Filling In Items With Null Values

Posted 14 May 2016 - 09:36 PM

Working on another project with a Data Repeater and running across what seems like a ReDraw issue.....

So i am reading data from an Access database. It is structured basically like this:
----------------------------------------------------------
| CustomerContact | ContactPhone | ContactEmail |
----------------------------------------------------------
| Darren Simpson | 817-555-5785 | [email protected] |
| Jeremy Keeton | 469-555-5785 | |
| JORGE | 214-555-5785 | [email protected] |
----------------------------------------------------------

On my Data Repeater, i have each field displayed as a Label control (LinkLabel actually for the email field)

The problem i'm having is that in the case of NULL data (ie. Jeremy Keeton's email), it will display properly until you scroll through the records. When you do that, any items that should be blank (NULL) get filled in with random values from other records (Jeremy's email LinkLabel may be filled with the Darren's email address)

i've tried every variation of this (code below) that i can think of visible, forecolor (linkcolor), etc. to no avail

Private Sub DataRepeater1_DrawItem(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) Handles DataRepeater1.DrawItem
With e.DataRepeaterItem
            .Controls(ContactEmailLinkLabel.Name).Visible = True

            If String.IsNullOrEmpty(.Controls(ContactEmailLinkLabel.Name).Text) Then
                .Controls(ContactEmailLinkLabel.Name).Visible = False
            End If
End With
End Sub



or

Private Sub DataRepeater1_DrawItem(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) Handles DataRepeater1.DrawItem
With e.DataRepeaterItem
            DirectCast(.Controls(ContactEmailLinkLabel.Name), LinkLabel).LinkColor = .Controls(ContactEmailLinkLabel.Name).BackColor

            If Not String.IsNullOrEmpty(.Controls(ContactEmailLinkLabel.Name).Text) Then
                DirectCast(.Controls(ContactEmailLinkLabel.Name), LinkLabel).LinkColor = Color.Blue
            End If
End With
End Sub



I don't know what else to do. This is making my data EXTREMELY unreliable. It happens in every case of NULL data, some records are missing Phone Numbers, Some are missing Names, and it all gets filled with data from other records. Help!

Is This A Good Question/Topic? 0
  • +

Replies To: Data Repeater Filling In Items With Null Values

#2 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6792
  • View blog
  • Posts: 28,050
  • Joined: 12-December 12

Re: Data Repeater Filling In Items With Null Values

Posted 15 May 2016 - 12:26 AM

Did you specify the last nullValue argument when binding controls?

ControlBindingsCollection.Add Method (String, Object, String, Boolean, DataSourceUpdateMode, Object)
Was This Post Helpful? 0
  • +
  • -

#3 royclay   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-May 19

Re: Data Repeater Filling In Items With Null Values

Posted 03 May 2019 - 11:58 AM

View Postcpilawski, on 14 May 2016 - 09:36 PM, said:

Working on another project with a Data Repeater and running across what seems like a ReDraw issue.....

So i am reading data from an Access database. It is structured basically like this:
----------------------------------------------------------
| CustomerContact | ContactPhone | ContactEmail |
----------------------------------------------------------
| Darren Simpson | 817-555-5785 | [email protected] |
| Jeremy Keeton | 469-555-5785 | |
| JORGE | 214-555-5785 | [email protected] |
----------------------------------------------------------

On my Data Repeater, i have each field displayed as a Label control (LinkLabel actually for the email field)

The problem i'm having is that in the case of NULL data (ie. Jeremy Keeton's email), it will display properly until you scroll through the records. When you do that, any items that should be blank (NULL) get filled in with random values from other records (Jeremy's email LinkLabel may be filled with the Darren's email address)

i've tried every variation of this (code below) that i can think of visible, forecolor (linkcolor), etc. to no avail

Private Sub DataRepeater1_DrawItem(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) Handles DataRepeater1.DrawItem
With e.DataRepeaterItem
            .Controls(ContactEmailLinkLabel.Name).Visible = True

            If String.IsNullOrEmpty(.Controls(ContactEmailLinkLabel.Name).Text) Then
                .Controls(ContactEmailLinkLabel.Name).Visible = False
            End If
End With
End Sub



or

Private Sub DataRepeater1_DrawItem(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) Handles DataRepeater1.DrawItem
With e.DataRepeaterItem
            DirectCast(.Controls(ContactEmailLinkLabel.Name), LinkLabel).LinkColor = .Controls(ContactEmailLinkLabel.Name).BackColor

            If Not String.IsNullOrEmpty(.Controls(ContactEmailLinkLabel.Name).Text) Then
                DirectCast(.Controls(ContactEmailLinkLabel.Name), LinkLabel).LinkColor = Color.Blue
            End If
End With
End Sub



I don't know what else to do. This is making my data EXTREMELY unreliable. It happens in every case of NULL data, some records are missing Phone Numbers, Some are missing Names, and it all gets filled with data from other records. Help!



I had this exact problem - took me forever to figure out that the repetition was caused by nulls in the database.. Using an MSSQL database. I used a COALESCE function to replace any possible nulls with empty strings and it worked fine
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1