-
checkbox datagrid
i have a checkbox column in my datagrid
id = chkSelected
now i want if that is true then the colour is "green"
it maybe simple enough but im having a nightmare with it:ehh:
any help or links would be much appreciated
NB i shall make this row then invisible as i wish to check the row under certain conditions, i dont think this shall effect my above problem though
i just really want to say if its checked then its this colour
-
Re: checkbox datagrid
override the databind even for the datagrid.
For each row, find that control and verify the "checked" property.
If it is checked, either modify the appropriate cell's background color in the row, or apply a style to the row itself that colors the backgrounds.
Changing the background should be akin to (from my head, here, not checked in VS)
e.Item.Cells[0].Style.BackgroundColor = "#AAFFAA"; //AAFFAA is one shade of green
-
Re: checkbox datagrid
Why not #00FF00? That's discrimination based upon color.
-
Re: checkbox datagrid
=D
Cause it is TOO green, ick!
-
Re: checkbox datagrid
Is this an updatable datagrid or just used for displaying the data without any need of editing the data.
Becoz if its an updatable one you have check if the checkbox is checked while binding the data as Lord said by writing in the databind event and if the user explicitly checks it then u can as well check in checkboxchanged event.
-
Re: checkbox datagrid
data wont be edited in it
i have some kind of clours workin on it now but it definitely isnt working right,
the checkbox is not databound so is there a way of making the checkbox stay checked on that row even after refreshes, i shall i need a bound column to determine row colours,, thanks
-
Re: checkbox datagrid
i need the row to be checked when select is pressed, this then needs to leave the row checked for good,
perheps i need to look at this differently
-
Re: checkbox datagrid
Lord Rat's setting the color command should work. You probably want to do it in the DataGrid1_ItemDataBound(..) event.
-
Re: checkbox datagrid
As for the checkbox being checked, you need to store in a persistent variable the checked/unchecked values of all the checkboxes and refresh that on every item databound. Persisting arrays can be accomplished using either the Session object or the ViewState object.