This is a migrated thread and some comments may be shown as answers.

Grid Code

3 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dip
Top achievements
Rank 1
Dip asked on 09 Jul 2008, 06:44 PM

GridView

oGridView = (GridView)sender;

GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);

TableCell oTableCell = new TableCell();

//Add Department

oTableCell.Text =

"Customer Info";

oTableCell.ColumnSpan = 3;

oGridViewRow.Cells.Add(oTableCell);

//Add Employee

oTableCell =

new TableCell();

oTableCell.Text =

"Contact";

oTableCell.ColumnSpan = 4;

oGridViewRow.Cells.Add(oTableCell);

oGridView.Controls[0].Controls.AddAt(0, oGridViewRow);


This code is in Asp.net. I am trying to modify the header with the an Event. But with telerik i didn't find any RadGridView etc...How can we do it with RadGrid..

Thanks,
DIP 

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Jul 2008, 07:15 AM
Hi Dip,

You can add a TableCell to the column header in RadGrid as shown below.


ASPX:
<telerik:GridBoundColumn DataField="ValueCol" HeaderText="ValueCol" SortExpression="ValueCol" 
                            UniqueName="ValueCol" ></telerik:GridBoundColumn> 

CS:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridHeaderItem) 
        { 
            GridHeaderItem headeritem = (GridHeaderItem)e.Item; 
            TableCell cell = new TableCell(); 
            cell.ID="CustomCell"
            cell.Text = "CustomText"
            cell.ColumnSpan = 3
            cell.BackColor = System.Drawing.Color.Pink; 
            headeritem["columnUniqueName"].Controls.Add(cell); 
 
         } 
   } 


Thanks
Shinu
0
Dip
Top achievements
Rank 1
answered on 10 Jul 2008, 12:46 PM
Hi Shinu,

You almost solved by problem, But I wanted it above the Header..And i have to do it on the Event (ItemDataBound)...How can be replace

GridViewRow

oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);

Once I can change  this code for Telerik ...I will be done....

0
Princy
Top achievements
Rank 2
answered on 11 Jul 2008, 07:00 AM
Hi Dip,

I dont think it is possible to place a cell above the Grid Row. But you can use the CommandItemTemplate to achieve this. Add the cells to the CommandItemTemplate.
Command item template

Thanks
Princy.
Tags
Grid
Asked by
Dip
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Dip
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or