Determine view in Datagrid based on Checkbox selected

X

xianxian

Hi guys,

I'm having trouble getting my Datagrid to display according to
Checkboxes checked values.

On my Checkboxes, I have 5 values :-
1) Apartment/Condo
2) Executive Condo
3) Detached
4) Semi-detached
5) Terrace

On my Datagrid, 2 columns r displayed according to what is Checked.
The columns :-
1)Floor Area
2)Land Area

This is how it goes..
(a)When Apartment/Executive Cdo is Checked, Land Area is not supposed to
be shown.
(b)When Detached/Semi-detached/Terrace is Checked, Floor Area is not
supposed to be shown.
(c)Naturally, if both items from (a) & (b) r Checked, both Land Area &
Floor Area should be shown.


Can somebody tell me how this should be done?

best regards,
xianxian
 
G

Guest

Hi xianxian,

You can set visibility of Floor Area/Land Area in datadrid_ItemDatabound
event:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem){
// according to condition
e.Item.Cells[Floor_index].Visible = true/false;
e.Item.Cells[Land_index].Visible = true/false;
}

HTH

Elton Wang
(e-mail address removed)
 
X

xianxian

Hi,

im sorry i didn specify to u further :-

1)The CheckBoxList & the Datagrid are on 2 separate web pages.
CheckboxList is on "Search" page, Datagrid on "Results" page.
2)i have stored all user's Checked values in ArrayList, so i can Loop
the ArrayList on "Results" page & get what is selected.

From the Loop, i can set the Visible property of the Datagrid column to
true/false. But i was lost admist all the Looping..


For i = 0 To a.Count - 1

Select Case p.GetItem(i)

Case 0, 1
dgProject.Columns.Item(3).Visible = False
Case 2
dgProject.Columns.Item(2).Visible = True
If Not dgProject.Columns.Item(3).Visible = False Then
dgProject.Columns.Item(2).Visible = False
Else
dgProject.Columns.Item(3).Visible = True
End If
Case 3
...
Case 4
...
End Select
Next


**p.GetItem(i) returns 0,1,2,3, or 4.
These 5 values are the Apartment/Executive Cdo, Detached, Semi-Detached
& Terrace respectively.

**dgProject.Columns.Item(2) is the column "Floor Area"
dgProject.Columns.Item(3) is "Land Area"

-----------------------------------------------------
For Case 2 it works.. but if i use its Loop in Case 3 & 4, it won't
work.
ie. When Apartment/Executive Cdo, Detached & Semi-Detached are Checked,
only "Land Area" is shown.

I am lost for Case 3 & 4.. i don't know how to Loop in there.

What should i do ?

thanks,
xianxian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top