Sort or filter unbound column of a bound datagridview

I have a bound datagridview. I have added two unbound columns. After i verify the data of the  grid, set forcolor of the cell that has invalid value and i set this unbound column's checkbox to be true. In order for me to be able to check, i had to set the grid's virtualmode = false . So far everything is working well.
Now, I want to sort my grid based on this new unbound column i call "FailedData" so that all the rows with checked "FailedData" will be together so that user knows which rows should be edited. i can either filter and show only the rows with checkbox checked or sort. But according to msdn, you can not sort  unbound column of a bound datagriedview.
Any suggestion?
RekhaShahAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

UnifiedISCommented:
Can you include the 2 new columns with your bound data source?  They don't need a value until your validation and you could hide them (visible = false) until you need to show them if you want.

0
RekhaShahAuthor Commented:
i guess, I can try it.  But ideally, i would like to sort of filter. Can you filter rows based on formatting? e.g.display only the rows with any of the cell with red fore color?
0
UnifiedISCommented:
If your 2 new columns are part of your data source then you will be able to sort by those columns.  

yes, could filter based on formatting but I don't think you could sort based on formatting.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

RekhaShahAuthor Commented:
How would you filter based on formatting?
 also, even for filtering based on formatting, I do need to make these columns part of my database. right?
0
UnifiedISCommented:
Filtering based on formatting is possible but logically, it's backwards.

As for part of the database, you don't need to add columns to tables but you do need to add columns to your query.

A SQL query with a "fake" column to be populated later in code:
SELECT *, '' AS FailedData FROM Table

0
RekhaShahAuthor Commented:
So,  i think, i should populate  my FailedData column in the stored procedure and then get the recordset, and now business as usual? Let me try it this evening and post back again.  i was  thinking about doing the same thing, but thought if I can do it at UI level, it will save me the trouble of writing a complex stored procedure.
Thanks
0
UnifiedISCommented:
I think that will do it.  Your stored procedure doesn't need to include any additional logic than is currently being used to provide data.  You just need to add a column which you will populate via your UI.  When you verify your data, populate the FailedData column with some value and you will be able to sort those to the top or bottom using the datagridview's sort method.
0
RekhaShahAuthor Commented:
It does not work because, I have all the columns readonly. I added FailedData column to database table. but now during verify process, when I set the checkbox of this column to true, first time it works and then it gives me an error that datareader is already open.close first!
0
UnifiedISCommented:
You should close your datareader as soon as you have read your data.  It sounds like you may have to make some other changes to your code as well.  
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RekhaShahAuthor Commented:
Thanks you for your help.
I implemented nested datareader so that going through each row, if i found any invalid data, i could set FailedData field to true. I am posting this comment so that it may be useful to someone else. But inorder to tdo nested Datareaders, I had to set MARS=true in sql connection string. That did the trick.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.