By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,030 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,030 IT Pros & Developers. It's quick & easy.

Determine view in Datagrid based on Checkbox selected

P: n/a
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

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
el********@hotmail.com
"xianxian" wrote:
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

*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #2

P: n/a
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

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3

P: n/a
hi,

i have solved the looping. Thank u very much for trying to help :)

*** Sent via Developersdex http://www.developersdex.com ***

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.