The function is returning no items. Following is a copy of my markup and code:
The markup looks like this:
I would really appreciate if somebody can tell me what I'm doing wrong here!
protected void Page_Load(object sender, EventArgs e)
{
RadGrid1.DataSource = GetDataSource();
RadGrid1.DataBind();
}
private DataTable GetDataSource()
{
...
}
private void AddGroupHeadersToGrid()
{
GridItem[] header = RadGrid1.MasterTableView.GetItems(GridItemType.Header);
//GridTHead head = ((GridTHead)header[0].Parent.Controls[0].Parent);
GridHeaderItem newHeaderItem = new GridHeaderItem(RadGrid1.MasterTableView, 0, 0);
newHeaderItem.Cells.Add(new GridTableHeaderCell());
newHeaderItem.Cells[0].Text = "I'm a header.";
//head.Controls.AddAt(0, newHeaderItem);
}
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
AddGroupHeadersToGrid();
}
The markup looks like this:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
onprerender
=
"RadGrid1_PreRender"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"Question"
DataField
=
"Question"
UniqueName
=
"Question"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Score"
DataField
=
"MTDScore"
UniqueName
=
"MTDScore"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Area"
DataField
=
"MTDArea"
UniqueName
=
"MTDArea"
>
<
telerik:GridBoundColumn
HeaderText
=
"Score"
DataField
=
"QTDScore"
UniqueName
=
"QTDScore"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Area"
DataField
=
"QTDArea"
UniqueName
=
"QTDArea"
>
<
telerik:GridBoundColumn
HeaderText
=
"Score"
DataField
=
"YTDScore"
UniqueName
=
"YTDScore"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Area"
DataField
=
"YTDArea"
UniqueName
=
"YTDArea"
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
I would really appreciate if somebody can tell me what I'm doing wrong here!