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

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

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

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:
    541
    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,424
    =?Utf-8?B?ZWNvZGVy?=
    Oct 14, 2005
  3. =?Utf-8?B?RG90TmV0RGV2?=

    DataGrid and embeded Checkbox..How to find if checkbox clicked

    =?Utf-8?B?RG90TmV0RGV2?=, Oct 6, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,013
    David Wier
    Oct 6, 2006
  4. mldardy
    Replies:
    0
    Views:
    1,145
    mldardy
    Sep 28, 2010
  5. Bnob

    Datagrid selected items with checkbox

    Bnob, Aug 11, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    5
    Views:
    443
    Ken Cox [Microsoft MVP]
    Aug 13, 2004
  6. hangar18
    Replies:
    0
    Views:
    236
    hangar18
    Mar 22, 2006
  7. Parthiv Joshi
    Replies:
    1
    Views:
    1,086
    Samuel L Matzen
    Jul 6, 2004
  8. asp123 vbnet via .NET 247

    Adding Checkboxlist/checkbox to dataGrid and retrieving selected value

    asp123 vbnet via .NET 247, Mar 25, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    820
    asp123 vbnet via .NET 247
    Mar 25, 2005
Loading...