0

Dear Colleagues

I have a problem with sorting in DataGridView module. When i click on column which needs to be sort then system throws NullReferenceException. I understand that column has some null values and this couses error message. Have You got any idea how to change sort module to thread null values as string without any characters?

Your prompt will be appreciated.

3 Answers 3

1

Why not use an empty string instead of null strings?

Sign up to request clarification or add additional context in comments.

1 Comment

Hi George, I can not use empty string because I take all data from database (postgresql) which couldnot be changed :(((
1

I know this is a bit complicated for your need but you could try a workaround similar to this after programmatically selecting those rows that have nulls in them.

Sorting selected rows in DataGridView

1 Comment

Hi Mamta, Your solution is little bit complicated for me but I found other solution which i described above.
0

Dear Geaorge and Mamta

Thank You both once again for help. I have found solution which ease resolved problem. As I wrote, all data is transfered from database to visual studio, so I changed query from:

"SELECT number_of_invoice FROM invoices"

to:

"SELECT CASE WHEN (number_of_invoice is null) then '' else number_of_invoice END FROM invoices"

This automaticly change null values to '', and problem is dismissed.

Have a good day!

1 Comment

That's great, thanks for sharing what you found. You can accept your own answer as the correct one so that it would help other users.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.