DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Hiding Dataset columns in a databound grid

  1. #1
    Jonny Guest

    Hiding Dataset columns in a databound grid

    All

    Do you know how to hide columns in a databound Datagrid control?

    I want to programatically set my Datagrid's DataSource to my DataSet but I
    do not want it to show all the columns. Its not too much to ask, surely.

    The only way I can see how to do this is to hand code all the frikking
    <ASP:EmployMonkeyToDoThis> tags (actually <asp:BoundColumn> tags) in the
    smelly HTML, and 'simply' miss out the columns I want to hide.

    So you want to hide one column out of 200 you 'simply' add 199 lines of
    cryptic monkey tags and there you have it, one hidden column.

    But since this is such a ludicrous solution I feel that surely Uncle Bill
    would not have let it past his benevolent gaze and into the beta.

    Can any of you kind folks throw me a bone here?

    Jonny




  2. #2
    Tim Romano Guest

    Re: Hiding Dataset columns in a databound grid

    Can't you bind your grid to a query/view that does not display the columns
    you want to be invisible?
    Tim Romano


    "Jonny" <jonny@joyofvb.com> wrote

    >
    > Do you know how to hide columns in a databound Datagrid control?
    >
    > I want to programatically set my Datagrid's DataSource to my DataSet but I
    > do not want it to show all the columns. Its not too much to ask, surely.
    > [...]
    > Can any of you kind folks throw me a bone here?
    >
    > Jonny





  3. #3
    Jonny Guest

    Re: Hiding Dataset columns in a databound grid

    Tim

    > Can't you bind your grid to a query/view that does not display the columns
    > you want to be invisible?
    > Tim Romano


    Thanks for this.

    The thing is I do want to have to hit the DB again when I have all the data
    I need in the DataSet already. I have tried creating a new dataset from the
    original (requery the dataset) but that only works for RowFiltering and not
    Selecting a subset of the Columns (you can only specify the 'where' clause
    and not the 'select' clause)

    Anyhoo, its all a bit boring really so I think I will stop now.

    Jonny



  4. #4
    Jonny Guest

    Re: Hiding Dataset columns in a databound grid

    Tim

    > Can't you bind your grid to a query/view that does not display the columns
    > you want to be invisible?
    > Tim Romano


    Thanks for this.

    The thing is I don't want to have to hit the DB again when I already have
    all the data I need in the DataSet.

    I have tried creating a new dataset from the original (requery the dataset)
    but that only works for RowFiltering and not Selecting a subset of the
    Columns (you can only specify the 'where' clause and not the 'select'
    clause).

    I tried cloning the DS then removing the columns from the clone but that did
    not work (I think you would have to remove them from the underlying XML
    schema).

    Anyhoo, database work is very boring so I think I will stop pestering you
    now. I am sure I will work it out.

    Jonny






  5. #5
    Kathleen Dollard-Joeris Guest

    Re: Hiding Dataset columns in a databound grid

    Jonny,

    Have this on my list of things to work out. Was planning on using a dataset
    view. Have you looked into that. Agree that you want to retrieve the proper
    columns for processing from the database. But in reading over the docs, the
    dataset view seemed just the tool for controlling columns for display.

    Let me know how it goes. I will let you know if it makes it to the top of my
    list.

    --
    Kathleen
    (MS-MVP)
    Reply in the newsgroup so everyone can benefit
    --



  6. #6
    Jonny Guest

    Re: Hiding Dataset columns in a databound grid

    Kathleen

    > Agree that you want to retrieve the proper
    > columns for processing from the database. But in reading over the docs,

    the
    > dataset view seemed just the tool for controlling columns for display.


    I finally decided to go with the client-side solution and and define my
    visible grid-columns by adding <databind> tags to the grid definition in the
    aspx doc.

    I am still confused as to why I was not allowed to instantiate new views
    based on an existing dataset, I suspect it is because I use Typed datasets
    (via the generated XSD file) for the base dataset and so you cannoot remove
    columns without violating the schema (I am guessing here). Now I think I
    might have misunderstood what a Dataview object is for. Maybe they map
    (functionally) to the SQLServer Views?

    Anyway, it works fine if you let the client sort out the UI.

    Jonny





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center