Koray Kırdinli

Yazılım ve İş Yaşamı Hakkında Paylaşımlar

Gridview’e Freeze Özelliği Eklemek

1-  Gridimizi 2 tane panel içine alıyoruz ve her bir kolona width veriyoruz.

—-şsadsadas

2-  Page load da da aşağıdaki metodu çağırıp freze özelliğini kolayca eklemiş oluyoruz.

FreezeGridviewHeader(GridRequestProgress, _tb, PanelContainer, grid1.Width.Value);

protected void FreezeGridviewHeader(GridView _gv1, Table _tb1, Panel _pc1, double panelWidth)

{

_gv1.EnableViewState = false;

_tb1.Rows.Add(_gv1.HeaderRow);

_tb1.Rows[0].ControlStyle.CopyFrom(_gv1.HeaderStyle);

_tb1.CellPadding = _gv1.CellPadding;

_tb1.CellSpacing = _gv1.CellSpacing;

_tb1.BorderWidth = Unit.Pixel(1);

_tb1.GridLines = GridLines.Vertical;

_pc1.Width = Unit.Pixel(panelWidth.ConvertToInt());

for (int Count = 0; Count < _gv1.HeaderRow.Cells.Count – 1; Count++)

{

_tb1.Rows[0].Cells[Count].Width = _gv1.Columns[Count].ItemStyle.Width;

_tb1.Rows[0].Cells[Count].BorderWidth = _gv1.Columns[Count].HeaderStyle.BorderWidth;

_tb1.Rows[0].Cells[Count].BorderStyle = _gv1.Columns[Count].HeaderStyle.BorderStyle;

_pc1.Width = Unit.Pixel(Convert.ToInt32(_tb1.Rows[0].Cells[Count].Width.Value) + Convert.ToInt32(_pc1.Width.Value) + 4);

}

for (int i = 0; i < _gv1.HeaderRow.Cells.Count – 1; i++)

{

_gv1.HeaderRow.Cells[i].Width = _tb1.Rows[0].Cells[i].Width;

_gv1.HeaderStyle.Width = _tb1.Rows[0].Cells[i].Width;

}

//_pc1.Width = Unit.Pixel(Convert.ToInt32(_tb1.Rows[0].Cells[Count – 1].Width.Value) + 12);

}

October 11, 2011 - Posted by | ASP.NET | , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s