Determine view in Datagrid based on Checkbox selected

Discussion in 'ASP .Net' started by xianxian, Jul 20, 2005.

  1. xianxian

    xianxian Guest

    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 ***
     
    xianxian, Jul 20, 2005
    #1
    1. Advertising

  2. 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



    "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 ***
    >
     
    =?Utf-8?B?RWx0b24gVw==?=, Jul 20, 2005
    #2
    1. Advertising

  3. xianxian

    xianxian Guest

    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 ***
     
    xianxian, Jul 21, 2005
    #3
  4. xianxian

    xianxian Guest

    xianxian, Jul 21, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Smith
    Replies:
    2
    Views:
    478
    Alex Smith
    Jun 10, 2005
  2. =?Utf-8?B?ZWNvZGVy?=

    Copy checkbox selected datagrid items into new dataset

    =?Utf-8?B?ZWNvZGVy?=, Oct 10, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,330
    =?Utf-8?B?ZWNvZGVy?=
    Oct 14, 2005
  3. mldardy
    Replies:
    0
    Views:
    995
    mldardy
    Sep 28, 2010
  4. hangar18
    Replies:
    0
    Views:
    146
    hangar18
    Mar 22, 2006
  5. Parthiv Joshi
    Replies:
    1
    Views:
    776
    Samuel L Matzen
    Jul 6, 2004
Loading...

Share This Page