 |
|
 |
No working for dynamic grid. Still gives a fair idea to implement. Thanks
|
|
|
|
 |
|
|
 |
|
 |
Doesn't work with horizontal scrolling or a dynamic grid with a large number of columns. Basically useless.
|
|
|
|
 |
|
 |
Creating 2 tables with fixed column widths is basically wishful thinking. You cannot set width: 100% because then header and data columns will have different widths. This seems like working but is a terrible solution. There are way better ones on the net.
|
|
|
|
 |
|
 |
Hello nsimeonov,
It is just another way, you have the last word.
But, thanks you, for the time answering.
Antonio.
Antonio Suarez
|
|
|
|
 |
|
 |
Very bad solution! You are obligated to set column widths and we all know rendering html doesn't always stick to what you set. DO NOT USE THIS CODE!
|
|
|
|
 |
|
 |
Hii,
This code is not working show error???????
code is here.......
///where sorting is Occur and this function is called
if (gridview1.Rows.Count != 0)
{
Table tab1 = new Table();
FreezeHeader(gvTable,tab1,Panel1);
}
///the function is here........
protected void FreezeHeader(GridView _gv, Table _tbl, Panel _pnl)
{
Page.EnableViewState = false;
_tbl.Rows.Add(_gv.HeaderRow);
_tbl.Rows[0].ControlStyle.CopyFrom(_gv.HeaderStyle);
_tbl.CellPadding = _gv.CellPadding;
_tbl.CellSpacing = _gv.CellSpacing;
_tbl.BorderWidth = _gv.BorderWidth;
int count=0;
_pnl.Width = Unit.Pixel(660);
for(count=0;count<_gv.HeaderRow.Cells.Count-1;count++)
{
_tbl.Rows[0].Cells[count].Width = _gv.Columns[count].ItemStyle.Width;
//error in this line
error is--------
///Index was out of range. Must be non-negative and less than the size of the collection.
///Parameter name: index
_tbl.Rows[0].Cells[count].BorderWidth = _gv.Columns[count].HeaderStyle.BorderWidth;
_tbl.Rows[0].Cells[count].BorderStyle = _gv.Columns[count].HeaderStyle.BorderStyle;
_pnl.Width = Unit.Pixel(Convert.ToInt32(_tbl.Rows[0].Cells[count].Width.Value) + Convert.ToInt32(_pnl.Width.Value) + 14);
}
}
|
|
|
|
 |
|
 |
if (gridview1.Rows.Count != 0)
{
gridview1.HeaderRow.Style.Add("position", "relative");
gridview1.HeaderRow.Style.Add("z-index", "10");
gridview1.HeaderRow.Style.Add("top", "expression(this.offsetParent.scrollTop-3)");
Panel1.Style.Add("overflow", "auto");
}
Response.Write("Inside:");
///last line for the panel where gridview is set.
it also works with dynamic gridvirw
|
|
|
|
 |
|
 |
the freeze headers will not work if you use pagerTemplate in the gridview
|
|
|
|
 |
|
 |
Hello imran prasla,
I do not made this to use paging because the freeze header, so I did not test using pageTemplate, maybe you could fix it and send me the code to update the article.
In what way do you want to use the article, maybe I could help you?
Thank you.
Antonio Suarez
|
|
|
|
 |
|
 |
I have a gridview where i am populating more than 1000 records. I have my own custom pager for gridview where I display page numbers and records count etc. If I use the freeze header technique that you discussed in your article, it will only freeze the headers and upon scrolling it will scroll page numbers' portion along with other rows as well. If you know a way of freezing headers with pager area (that uses the PagerTemplate) then do let me know. Apart from that the article is very good.
|
|
|
|
 |
|
 |
I think you could "clone" the pager row, as I do with the header, and put out side of the panel where the gridview is.
Thank you.
Antonio Suarez
|
|
|
|
 |
|
 |
it is not working properly for me.I manage to freeze header but when I save my data,ist row data refer to second row and so on thats why all my data saved with wrong referece.
please suggest.
Thanks.
|
|
|
|
 |
|
 |
I am kinda a newbie at all this ....so what would the code look like you have to add in the aspx page ....
Thanks ....Brian
qtrmile69@hotmail.com
|
|
|
|
 |
|
 |
Just for the freezing portion
|
|
|
|
 |
|
 |
I was able to get edit mode to work by removing the following line from the FreezeGridviewHeader function:
Page.EnableViewState = false;
I then added the edit command manually to the datagrid; setting the width to be long enough to handle the update and cancel commands when the edit button is clicked:
<asp:CommandField ShowEditButton="true" ItemStyle-Width="200px" />
I then adjusted the width of the container panel to match the width of all the columns.
It would be nice however, to figure out the size of the columns at runtime though. This would make it much easier to make changes, and allow for dynamic column widths.
Thanks Antonio, this is a very elegant solution without having to get mixed up in the css maze of different browsers.
|
|
|
|
 |
|
 |
Hello Scott,
I will update the files with your suggestions.
Yes i did the same with the columns width in a project, but I hope we can find the way to do it at runtime.
Thank you.
Antonio Suarez
|
|
|
|
 |
|
 |
I continued to have problems with trying to get the edit mode to work. If I removed the Page.EnableViewState = false line, my grid would not freeze the header.
I modified the code to _pc1.EnableViewState = false; to set the panel's view state to false. I then created my own methods to edit and write the data changes back from the datagrid. I needed to remove the Page.EnableViewstate line because it was affecting other controls on my page. This does not completely solve the Edit funtionality question, but it certainly accomplished what I needed done.
Thank you Antonio for providing this solution, and thanks Scott for pointing me in the right direction.
|
|
|
|
 |
|
 |
I am getting two identical header rows on sort and edit. Any ideas?
|
|
|
|
 |
|
 |
Hello Scottlis,
Sorry if i make you wait for an answer, but I did not see the e-mail.
You are using the edit mode, check the scott.m.owen@hotmail.com comments and use his modifications to fix the two headers problem.
Thank You.
Antonio Suarez
|
|
|
|
 |
|
|
 |
|
 |
Good job!
And it looks perfect when a few improvements have been executed:
default.aspx:
attribute Height for PanelGridViewData to 204px
attribute ScrollBars for PanelContainer to None
default.cs:
add 2 lines after for{...} in function FreezeGridviewHeader:
_tb1.Rows[0].Cells[_gv1.HeaderRow.Cells.Count - 1].Width = Unit.Pixel(Convert.ToInt32(_gv1.Columns[_gv1.HeaderRow.Cells.Count - 1].ItemStyle.Width.Value) );
_pc1.Width = Convert.ToInt32(_pc1.Width.Value -4);
|
|
|
|
 |
|
 |
Thank you Helmar,
I did your improvements and it works perfectly.
Did you try on edit mode?
Antonio Suarez
|
|
|
|
 |
|
 |
Dear expert.
This works great. Thank you so much. However, I hit one problem.
My web page has a formview and a gridview. After I added your functions to fix the gridview headers, the gridview worked fine; however, the UpdateButton stopped to work when clicked 1st time in the formview. I found it is due to the "Page.EnableViewState = false;" in your function. Removing this line solves the clicking problem of the formview update button, but then the headers will not fixed after post-back.
Is there a workaround for this? Thanks!
ChuChu
|
|
|
|
 |
|
 |
in your remarks it should be copying, not coping
Jon
Smith & Wesson: The original point and click interface
|
|
|
|
 |