ASP.NET CheckboxList and checking items in gridview

Hello,

in an edititemtemplate of a gridview representing incidents I placed a checkboxlist. The data I retrieve is a table with the fields ID,Description and Checked for each incident. In the past I used the rowdatabound event to check the listitems manually, but I wonder if there's another (easier) way to do this.

Thank you.
LVL 9
Stephan_SchrandtAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

_Katka_Commented:
Hi, you can create another column with boolean representation, and then display this column instead.

1) you've column myDbBooleanValue (not a boolean column actually)
2) create additional true boolean column myCalculatedBooleanValue, to be bound to a grid

You can then synchronize these two columns calculate via ColumnChanged event directly on the DataTable.

- if myDbBooleanValue is changed from '0' to '1', then myCalculatedBooleanValue is changed to True
- myCalculatedBooleanValue is changed to False, then myDbBooleanValue is changed to '0' (for example)

It would be maybe even better to encapsulate whole data to a class, and then make those changes based on property change.

So, create a class instance from a datatable row. Then bind the object to a grid, when done just generate changes via the object class.

regards,
Kate
0
Stephan_SchrandtAuthor Commented:
Thank you for your answer, maybe I did not express myself correctly. My problem is not to get the changes correctly but displaying them while binding the grid to a datasource.
Let's say you want to record phone calls and each call can have one or more categories. When you display a recorded call in your grid, you get a record for the call and n records for the categories. So when you enter edit mode in grid, you have to check some of the categories depending on the second datasource. My first thought was something like 'DataCheckedField' for checkboxlist, similar to the properties 'DataValueField' and 'DataTextField'.
0
masterpassCommented:
In the past I used the rowdatabound event to check the listitems manually >>>>> 

The situation still prevails, you have to loop through items to do any checking/unchecking of items. Also, it is the same, if you want to check whether an item is checked or not.
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
_Katka_Commented:
In this case, I don't think there's a different way of doing it. It has to be done manually, but you can try:

1) make some helper class to automatize this process or
2) create some descendant that will do it for you (but you'll still need to program it yourself)
3) use different components (usually not for free, BUT we're using DevExpress, and this can't still be automatized)

Sorry, maybe someone will offer you better solution, we solved this by making a descendant of the component to help us automatize the binding process, but still we need to do it manually (even thou it's easier).

regards,
Kate
0
Stephan_SchrandtAuthor Commented:
Thank you
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.