Hide column Header and data in ListView Asp.Net - c#

I have a ListView in my Asp.net application which has ItemTemplates. And data is bound to the listview. I want to give user flexibility to chose columns that they want to see in the ListView i.e. Show/Hide particular columns in the ListView. How can I achieve that? I tried
ListView1.FindControl("columnName").Visible = false;
But this only hides the column header and data in the ListView becomes out of order. What's the best way to achieve this?

Related

How to make custom header with data grid in WPF?

I want to make data grid with custom header. My header contains of Row Span and Column Span. So I have decided using grid as the layout and then datagrid as my control data.
You can see my header like this..
and then below that header I wanna make datagrid how I can do it? I'm still newbie in WPF and then how I can make the column in my grid layout can match datagrid that I have created below that?

WPF datagrid show data of all columns in one row

In datagrid I want to show list which is grouped, there is a style for datagrid row to show expander which shows basic information and then user has to expand to see more data (in terms of another datagrid). What I want to do in the expander is to aggregate the data of one column from the nested datagrid as part of basic information.
What is the best way to do it? Do I do it by making my ViewModel arrange the data for parent datagrid and bind that property? Or I can do it solely in XAML?

DomainUpDown control inside the GridView

I want to add DomainUpDown control inside a DataGridView as a separate column. Each time a new row is added, I want that DomainUpDown control also be added. I also want to know when the user click the DomainUp or DomainDown button in DomainUpDown control for each row. Is it possible or not? I am using language vb.net/C#. I want to do this in winform not in ASP. Any help or suggestion please!!!
All you need to do/know is how to add an unbound column to an already data bound DataGridView, because from your description you are trying to add a column to a grid which already contains other data bound columns. In fact it would be easier if you had such column in the DataTable, also because with unbound columns you need to make a slightly bigger effort to populate and save the data from/to somewhere.
anyway it should be possible, MSDN explains it here: How to: Add an Unbound Column to a Data-Bound Windows Forms DataGridView Control

hide columns by Id in gridview in asp.net

I have the asp.net application where I am having the editable grid view with the edit,Delete,Add options. this grid having as usual Template fields . I want to hide some columns. I know i can do that by using columns index. but i don't want to follow it. instead I want to hide columns by Id. this is because if in my application further I need to add more columns then there is need to change the code gain and again in the core. so I am choosing this way. Bu as i found <asp:TemplateField /> does not contain Id attribute. so it is become impossible for me to hide <asp:TemplateField/> by Id. any remedy for this ?
You can always do it using column header text. Run a loop through columns of the grid view and compare header text of the column with the constant declared and hide the column, this way, if you are adding any number of columns before or after the column will not affect the code.
Maybe create a div with an id inside a template field and hide that div with client code.
Perhaps just have a different grid markup for each "view" you want to show to the user, so one grid with all the columns, and another with limited columns.
I am assuming you would always be binding the same data to the grid (regardless of whether you are hiding/showing columns), so then you would just need some logic in your code to determine what "view" you want to show the user (i.e. what grid you want to bind to).

Display ASP.NET GridView inside a selected row in another GridView

I have been given a mockup that I do not know is possible to code in ASP.NET without being a real html and javascript wizard.
I want a GridView that when a row is selected, the selected row expands and below the selected row a panel of additional information is shown, which would also include another small GridView. The idea is this would all be in-line. So if the user selected row 4, then the additional information would appear below row 4 and then after the additional information the parent GridView would continue with row 5.
Ultimately I would want to do a multi-select type of set up, but first I need to figure out if this is even possible. Also, the solution must be 508 Compliant
The one solution I considered was using only one "column". Then I would put all my fields in the ItemTemplate, and my detail panel content in the EditItemTemplate and instead of selecting the row, set it to edit mode. The problem with this solution is I lose the functionality of multiple columns if I throw everything in one huge ItemTemplate.
Any and all suggestions or ideas are appreciated.
What you're describing would be best fulfilled with a ListView control. It takes a little more templating work to set up than a grid view, but you have much more control over it and you can emulate the look of a GridView. You would set your Selected Item template to contain another ListView (or GridView) thats bound to your detailed data.
I've done this using a gridview inside a ListView and using ajaxcontroltoolkit collapsible panel
Your parent list would be a listview that would have 2 table rows for each item, on the first row your parent column, on the second row use colspan and add a gridview wrapped on a collapsible panel

Categories

Resources