Gridview üzerine ana başlık eklemek için ” RowCreated ” eventini kullacağız. Gridview’i seçtikten sonra Eventler bölümünden RowCreated’e çift klik yapıyoruz. Event içerisine aşağıdaki kod bloğunu yazıyoruz.
if (e.Row.RowType==DataControlRowType.Header) { GridView oGridView = (GridView)sender; GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert); TableCell oTableCell = new TableCell(); oTableCell.Text = "Gercek Kisi Serhler"; //Baslik kisminda yazacak oTableCell.Style.Add("font-weight", "bold"); oTableCell.Style.Add("background-color", "#ffcc00"); oTableCell.Style.Add("color", "black"); oTableCell.Style.Add("text-align", "center"); oTableCell.Style.Add("font-size", "small"); oTableCell.ColumnSpan = 7;// kac tane kolonu kapsayacagini belirtiyoruz. oGridViewRow.Cells.Add(oTableCell); oGridView.Controls[0].Controls.AddAt(0, oGridViewRow); }
Kolay gelsin.