1 Replies - 2426 Views - Last Post: 16 February 2012 - 04:26 PM Rate Topic: -----

#1 Criel  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 124
  • Joined: 11-March 11

Allow Null values in listview?

Posted 16 February 2012 - 02:21 PM

Hello,

I've come across an error I'm not quite sure how to get rid of, I've got a listview with listview items making up the grid, I've got values coming from a database populating the cells however if there are any null values(in this case, there's null values in the date) it crashes my program. I'm not quite sure of a way to allow the listview to have null values in it, I figured it would default allow it but that's not the case.
itm.Text = m_Queue_rs.Fields(0).Value
                        itm.SubItems.Add(m_Queue_rs.Fields(1).Value)
                        itm.SubItems.Add(FormatAge(m_Queue_rs.Fields(2).Value))
                        itm.SubItems.Add(m_Queue_rs.Fields(3).Value)
                        itm.SubItems.Add(FormatCurrency(m_Queue_rs.Fields(4).Value))
                        itm.SubItems.Add(m_Queue_rs.Fields(9).Value)
                        itm.SubItems.Add(getReason(m_Queue_rs.Fields(17).Value))
                        itm.SubItems.Add(m_Queue_rs.Fields(6).Value)
                    itm.SubItems.Add(m_Queue_rs.Fields(10).Value)
                    itm.SubItems.Add(m_Queue_rs.Fields(7).Value)' This is where the error is occuring, it's fine if there's a value to put into the cell but once it becomes null it spits it out, I would like to know if there's a way for it to accept nulls.
                        itm.SubItems.Add(GetCodeTranslations("AuthQueueStatus", m_Queue_rs.Fields(8).Value))




Error is:
Overload resolution failed because no Public 'Add' is most specific for these arguments:
'Public Function add(text As String) As System.Windows.Forms.ListViewItem.ListViewSubItem':
Not most specifc
'Public Function Add(item as System.Windows.Forms.ListViewItem.ListViewSubItem) As System.Windows.Forms.ListViewItem':
Not most specific

This post has been edited by Criel: 16 February 2012 - 02:23 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Allow Null values in listview?

#2 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: Allow Null values in listview?

Posted 16 February 2012 - 04:26 PM

I'm pretty sure this work:
itm.SubItems.Add(m_Queue_rs.Fields(7).Value.ToString)
If not you could
1. Check for null and input a blank string instead of trying to insert the null entry
or
2. Append an empty string to what you have
itm.SubItems.Add(m_Queue_rs.Fields(7).Value & "")
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1