Gridview sorting issue - Column data vanishes - asp.net

I have a really weird issue. I have a Gridview, which I bind to a Dataview programtically. My Gridview has 11 columns. Sorting works fine as long as I do not remove any columns programtically.
In certain cases I remove 2 of the columns from the Gridview. Still not a problem. All the data is properly displayed however the problem occurs when I sort one of the columns. I sort the Dataview and bind to the Gridview again. Data from two of my columns just vanishes. Both of these columns are based on ItemTemplates. The columns are still displayed but just empty cells.
Any ideas? Thanks.

Instead of removing the columns, hide them. The bound item's indexes are confused by removing the columns from the grid only and not the DataSource.
A better solution would be not to ever render those columns at all if you are always hiding them. If there are conditions to which they are removed, then hide them. CSS is an easy way to do that.

Related

Is it possible to merge cells of a datagrid vertically in clarity framework

I want to create a datagrid that has cells that are vertically next to each other and has the same name merged. Tried to google many sources but couldn't find any help.
This is not possible with Clarity in a datagrid, as this breaks the pattern of rows holding content atomically. Pagination, rendering, sorting, filtering would all be much more complex to implement and understand for the user.
I would suggest that you use a regular table which can have column or row spans attached to a cell, or just have each row repeat the content in the cell instead of trying to merge it.

GridView extra header OR merged cells breaks Edit-Update

I need to add an extra header with merged cells to my gridview and it's quite easy to do it.
The problem is as soon a extra header exists in the GridView, the Edit-Update doesn't work anymore. Update to be precise. When I press Update, all the columns become empty and the extra-header's rows are gone.
Anyone achieved to add an extra header rows but with a working Update ?

How to display only those columns in the gridview according to which dropdownlist the user selects

For example i have three dropdownlists and the the user selects Say Name and PIN dropdownlist i want results that match the two to be displayed not any other what should I do?
Please help! :/
EDIT:
What i want to do is based on what dropdown list the user makes the selection from i want to display only those columns in the gridview on the next page and two fields name and pin corresponding to those rows will always be displayed ... if i try permutaion combinations i would have to make 81 sql queries. What should I do?
Each column has a Visible attribute; one approach could be to bind the entire list of columns, and show/hide only the columns you want to show. Alternatively, you could dynamically add the BoundField columns dependant on the selection.
HTH.

Drag and drop column data to another column

In Flex, using AdvancedDataGrid, I'm trying to achieve a drag and drop of one row's column data to another row's column or the same row but different column. Is this even possible? I've been googling for hours and all I can find are drag and drop whole columns just to rearrange their view order.
You have two options to make columns draggable.
First is to make all the columns draggable in the DataGrid. You can do this using the draggableColumns property on the DataGrid class. Set its value to true.
The second is to set the draggable property on the DataGridColumn class.
In both cases, you would drag the columns using the column header.
If you want to be able to drag a single cell, there is no way to do this that I know of.

How to collapse column in rdlc

We can use the hide property to display/hide column, but still it occupies column space
I want to collapse it same like we do in wpf, so if we don't want to see the column we can use the space for other columns.
Any solution?
Are you using Textboxes inside a List repeater to generate the table? That's what we were doing and we had the same problem you describe.
The solution was to switch to using a true Table. Columns in an RDLC table will collapse OK.
If you are using a Table are you setting the visibility of the column itself? Ensure you are setting the visibility of the entire column, not just the field.

Resources