471,089 Members | 1,776 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

Determine view in Datagrid based on Checkbox selected

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
3 1449
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
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
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.

Similar topics

reply views Thread by Krish | last post: by
5 posts views Thread by TPS | last post: by
2 posts views Thread by Bob Hollness | last post: by
2 posts views Thread by Mortar | last post: by
12 posts views Thread by Raed Sawalha | last post: by
1 post views Thread by mamun | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.