|
-
Oct 20th, 2005, 05:56 AM
#1
Thread Starter
Fanatic Member
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
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
it works 60% of the time, all the time.
-
Oct 20th, 2005, 12:14 PM
#2
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
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 20th, 2005, 12:39 PM
#3
Re: checkbox datagrid
Why not #00FF00? That's discrimination based upon color.
-
Oct 20th, 2005, 01:01 PM
#4
Re: checkbox datagrid
=D
Cause it is TOO green, ick!
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
-
Oct 20th, 2005, 02:27 PM
#5
Junior Member
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.
-
Oct 21st, 2005, 04:00 AM
#6
Thread Starter
Fanatic Member
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
it works 60% of the time, all the time.
-
Oct 21st, 2005, 04:01 AM
#7
Thread Starter
Fanatic Member
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
it works 60% of the time, all the time.
-
Oct 21st, 2005, 10:06 AM
#8
Fanatic Member
Re: checkbox datagrid
Lord Rat's setting the color command should work. You probably want to do it in the DataGrid1_ItemDataBound(..) event.
-
Oct 21st, 2005, 11:54 AM
#9
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.
Need to re-register ASP.NET?
C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i
(Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|