Freeze Columns In Gridview Where Grid Has Static Height And All Rows Are Rendered?
Feb 23, 2011
I'm trying to freeze columns in gridview where grid has static height and all rows are rendered(no paging and scroll var is visible).I only managed to add scroll through content by overflow property,but this time all columns are scrolling as well.My task is to freeze columns while maintaining column width.Let this be my grid
<div style="height:200px;overflow:auto;">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
UseAccessibleHeader="true or false">
I created a gridview that is made up of 4 gridviews and using a stored procedure to populate it. I create columns at runtime because the number of columns changes all the time.To make the grids editable I am adding template fields at runtime as I create the columns, this is to ensure that a user is able to edit the cells and some foot values update. Reason why I have four grids is to freeze rows and columns like in excel using javascript. The problem is that performance is very bad especially in IE, the grids take a long time to load. I am not sure if this is caused by the data load or the creation of text boxes. see some of the code below for my _aspx page:
I am trying to set the top gridview's column's width to the body's column width and then the left columns height to the body's coloumns height. Here is my code:
I have a gridview where I display (from left to right) plant id, product no and month/year and there after a column with qty for every day on the month.
The gridview is located inside a panel that has a horizontal scrollable property set that lets user scroll from left to the right. This works fine.
Now, they are asking if it is possible somehow to freeze plant id and product no? Currently when they scroll past day 10 then plant id and product no is not longer visible and making it hard to see what line you are on.
I'm binding a gridview from a webservice with 30 columns and 10 rows, I need to print the same in a PORTRAIT, for that i decided to display columns as rows and
I need to freeze my gridview header and the first two columns. I found a great jquery plugin called tinytbl which does the job but it messes up the inline javascript on my page which causes a few issues.
Any better way to freeze columns? I see alot of examples on the net using css but they use expression which has been deprecated.
My question is how to freeze specifi columns of Gridview control ? Freeze means...for example say if we are freezing the first column of grid then on scrolling a horizontal scroll bar of the grid will scroll all columns other than the first column. That means the first column will be visible always without any movement. But the first column should move if we use the vertical scroll bar.
Need row editing on page_load for all the cells and need to validate each cell entry. Means cell1 one entery isvalid it fills thrid cell and insert or update to a table in the database. How do i handle on tab clicking to update in databse.
If I have to show big text in gridview's particular column, then how can i control its height and width (especially) in ASP.NET C#so that i do not affect other columns height and width.
I have a situation where I need to freeze first two colums in a datagrid view control on my asp.net app. In windows forms there is a proprty called Freeze which can be enabled / disabled. How can I freeze first two colums in a data grid view control on my ASP.NET page.
I have to freeze the first column in a data grid. i have done freezing part but the issue is vertical and horizontal scroll bar movement getting slow. in my data grid each row contains 18 textboxes and 18 image buttons.if number of rows count around 15 then the scroll bars working almost properly.issue in morethan 15 rows
For freeze i am using CSS.Platform is asp.net1.1
in CSS i am using below given codes. div#div-datagrid { width: 200px; height: 200px; overflow: auto; } /* Locks the left column */ td.locked, th.locked { position:relative; cursor: default; left: expression(document.getElementById("div-datagrid").scrollLeft-1); } /* Locks table header */ th { font-size: 14px; font-weight: bold; text-align: center; background-color:Navy; color: white; border-right: 1px solid silver; position:relative; cursor: default; top: expression(document.getElementById("div-datagrid").scrollTop-4); z-index: 10; } /* Keeps the header as the top most item. Important for top left item*/ th.locked {z-index: 99;}
The "FilePath" and "AttachmentID" fields are being set correctly in the grid, however, the CheckBox control is never set correctly; it is always unchecked.
My question:
How do I get this CheckBox field set from C# as I'm creating the new row?
P.S. I am not sure if I am creating the row correctly in the first place.
I've got a grid view on my form that is bound to a data table at run tim. The data table is returned by a function rather than direct from the DB so I can't set the datasource at runtime.
I bind the grid in the page_load event like this:-
Code: Dim _dt As System.Data.DataTable _dt = _srvc.GetVinylShutters(0) _dt.Rows.Add(_dt.NewRow) grdShutters.DataSource = _dt grdShutters.DataBind() (_dt.Rows.Add(_dt.NewRow) is just there to add a blank row in, otherwise I wasn't seeing any columns at all)
I've then got the following snippet which I want to use to hide some underlying columns:-
Code: For Each col As DataControlField In grdShutters.Columns Select Case col.HeaderText Case "OrderID", _ "ShutterID", _ "ModelID", _
[Code] ...
The thing is, wherever I put this it doesn't seem to hide the columns. If I break into the code I can see that grdShutters.Columns.Count equals zero althought I can see that the bound datatable has 38 columns.
I've tried the Page's Load, LoadComplete and PreRenderComplete events as well as the gridview's DataBound, RowDataBound and RowCreated events. I get teh same result in all of them. The grid doesn't actually have any columns until it appears on the screen.
I am trying to set come columns to invisible after all of the rows are binded but I'm having trouble. I'm hiding columns that have empty data which I save in a session variable. This works fine. Then I tried changing the columns visible property using the ColumnByName routine in the DataBound but that must be the wrong event because I do not think the columns exist yet.
The columns are autogenerated btw.
Where can I set the columns properties after it has binded? Can i do this before the columns are autogenerated the the screen itself?
I have been looking at this article: [URL] However, I have a question: Can't this be used with a sqldatasource, instead of binding the gridview behind? If so, how?
I have a couple of things that are not working with my Gridview:
1) I've managed to display 3 columns in one column (see code above) but the data is separated by commas, how can I display each data item in separate rows.
2) How can I make the data unique, as I have added the distinct command which I configured in my SQL data source
3) I need the rows to not display nulls, but at the moment it isn't displaying the row if one of the columns is null?