473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 1570
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Just D | last post by:
Hi All, Does anybody know how to write the following code? I have a database table with a few columns including: ID , "Task" , ForceRun . I need to show the DataGrid on the ASPX page with...
0
by: Krish | last post by:
Hello Gurus, Pl. help. I need to validate a control in datagrid based on check box selection. Basically in a datagrid i have checkbox and textbox control for edititemtemplate. If checkbox is...
5
by: TPS | last post by:
I have a checkbox column in my datagrid. This checkbox triggers an autopostback. When I postback, I need to tell what row the user is on so I can tell what check box was checked or unchecked. ...
2
by: Bob Hollness | last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the questions I may ask! I have a datagrid which I have populated from a database. It works great! I have added a column, via...
2
by: Mortar | last post by:
i have a datagrid with 2 columns. the 1st column contains an id which will be used by the database for the selected checkbox records. the 2nd column is a template column containing a server...
12
by: Raed Sawalha | last post by:
I have the following table which i can not switcha to design view error message said Could not open in Design view. Quote values differently inside a '<% ...."value"... %>' block. and the...
1
by: mamun | last post by:
Hi All, I have the following situation. In the aspx page, I have a datagrid and getting values from the database. I am displaying checkbox in each row of the grid. At the top of the grid I...
4
by: mamun | last post by:
Hi All, I have the following situation and am looking for answer in C#. I have a datagrid and putting checkbox next to each record. In the header I have a Delete button. I want users to...
3
by: | last post by:
Hi all, I have a CheckBoxList control which has about 10 items. I have set autopostback=true and also set an eventhandler for OnSelectedIndexChanged. The problem is I want to identify which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.