I have a hierarchical radgrid that is displaying "No child records to display" even when records exist. See attached photo. Below is my RadGrid definition:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
ShowStatusBar
=
"true"
AutoGenerateColumns
=
"False"
AllowSorting
=
"True"
OnDetailTableDataBind
=
"RadGrid1_DetailTableDataBind"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnPreRender
=
"RadGrid1_PreRender"
GroupPanelPosition
=
"Top"
OnBatchEditCommand
=
"RadGrid1_BatchEditCommand"
Skin
=
"Office2010Black"
AllowFilteringByColumn
=
"True"
CellSpacing
=
"-1"
GridLines
=
"Both"
Visible
=
"false"
>
<
MasterTableView
DataKeyNames
=
"wbs_id"
RetainExpandStateOnRebind
=
"True"
AllowMultiColumnSorting
=
"True"
CommandItemDisplay
=
"Top"
>
<
DetailTables
>
<
telerik:GridTableView
runat
=
"server"
Width
=
"100%"
DataKeyNames
=
"task_id"
RetainExpandStateOnRebind
=
"True"
Name
=
"Steps"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"False"
></
CommandItemSettings
>
</
telerik:GridTableView
>
<
telerik:GridTableView
runat
=
"server"
Width
=
"100%"
DataKeyNames
=
"task_id"
RetainExpandStateOnRebind
=
"True"
Name
=
"Steps"
>
<
DetailTables
>
<
telerik:GridTableView
runat
=
"server"
Width
=
"100%"
DataKeyNames
=
"task_id"
RetainExpandStateOnRebind
=
"True"
EditMode
=
"Batch"
Name
=
"StepDetails"
CommandItemDisplay
=
"Top"
>
</
telerik:GridTableView
>
</
DetailTables
>
</
telerik:GridTableView
>
</
DetailTables
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"False"
></
CommandItemSettings
>
</
MasterTableView
>
<
PagerStyle
Mode
=
"NumericPages"
></
PagerStyle
>
<
MasterTableView
DataKeyNames
=
"wbs_id"
AllowMultiColumnSorting
=
"True"
CommandItemDisplay
=
"Top"
RetainExpandStateOnRebind
=
"true"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"false"
ShowRefreshButton
=
"true"
></
CommandItemSettings
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"task_id"
Name
=
"Steps"
Width
=
"100%"
RetainExpandStateOnRebind
=
"true"
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"task_id"
Name
=
"StepDetails"
Width
=
"100%"
EditMode
=
"Batch"
CommandItemDisplay
=
"Top"
RetainExpandStateOnRebind
=
"true"
>
<
CommandItemSettings
ShowSaveChangesButton
=
"true"
ShowCancelChangesButton
=
"true"
ShowAddNewRecordButton
=
"false"
/>
<
Columns
>
<
telerik:GridBoundColumn
SortExpression
=
"proc_id"
HeaderText
=
"proc id"
HeaderButtonType
=
"TextButton"
DataField
=
"proc_id"
Display
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"proc_name"
HeaderText
=
"Step Name"
HeaderButtonType
=
"TextButton"
DataField
=
"proc_name"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"proc_wt"
HeaderText
=
"Step Weight"
HeaderButtonType
=
"TextButton"
DataField
=
"proc_wt"
ReadOnly
=
"true"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"complete_pct"
HeaderText
=
"Percent Complete"
HeaderButtonType
=
"TextButton"
DataField
=
"complete_pct"
ReadOnly
=
"true"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"CompleteFlag"
DataField
=
"complete_flag"
HeaderText
=
"Complete"
ReadOnly
=
"true"
AllowFiltering
=
"false"
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"CheckBox1"
runat
=
"server"
Checked='<%#DataBinder.Eval (Container.DataItem,"complete_flag").ToString()!="N"? true:false %>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridDateTimeColumn
MinDate
=
"2013-01-01"
DataField
=
"act_start"
HeaderText
=
"Actual Start"
SortExpression
=
"act_start"
UniqueName
=
"act_start"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter act_start column"
DataFormatString
=
"{0:yyyy/MM/dd}"
ItemStyle-BackColor
=
"#c6f3ff"
AllowFiltering
=
"false"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridDateTimeColumn
MinDate
=
"2013-01-01"
DataField
=
"est_act_finish"
HeaderText
=
"Est/Actual Finish"
SortExpression
=
"est_act_finish"
UniqueName
=
"est_act_finish"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter est_act_finish column"
DataFormatString
=
"{0:yyyy/MM/dd}"
ItemStyle-BackColor
=
"#c6f3ff"
AllowFiltering
=
"false"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"complete_pct_upd"
HeaderText
=
"Updated Percent Complete"
HeaderButtonType
=
"TextButton"
DataField
=
"complete_pct_upd"
DataType
=
"System.Decimal"
ItemStyle-BackColor
=
"#c6f3ff"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"last_updated"
HeaderText
=
"Last Updated"
HeaderButtonType
=
"TextButton"
DataField
=
"last_updated"
ReadOnly
=
"true"
DataType
=
"System.DateTime"
DataFormatString
=
"{0:yyyy/MM/dd}"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"updated_by"
HeaderText
=
"Updated By"
HeaderButtonType
=
"TextButton"
DataField
=
"updated_by"
ReadOnly
=
"true"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"comments"
HeaderText
=
"Comments"
HeaderButtonType
=
"TextButton"
DataField
=
"comments"
ReadOnly
=
"false"
DataType
=
"System.String"
AllowFiltering
=
"false"
ItemStyle-BackColor
=
"#c6f3ff"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
SortExpression
=
"task_id"
HeaderText
=
"task_id"
HeaderButtonType
=
"TextButton"
DataField
=
"task_id"
Display
=
"false"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"task_code"
HeaderText
=
"Activity ID"
HeaderButtonType
=
"TextButton"
DataField
=
"task_code"
UniqueName
=
"task_code"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"task_name"
HeaderText
=
"Activity Name"
HeaderButtonType
=
"TextButton"
DataField
=
"task_name"
UniqueName
=
"task_name"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"start"
HeaderText
=
"Start"
HeaderButtonType
=
"TextButton"
DataField
=
"start"
UniqueName
=
"start"
DataType
=
"System.DateTime"
ReadOnly
=
"true"
DataFormatString
=
"{0:yyyy/MM/dd}"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"finish"
HeaderText
=
"Finish"
HeaderButtonType
=
"TextButton"
DataField
=
"finish"
UniqueName
=
"finish"
DataType
=
"System.DateTime"
ReadOnly
=
"true"
DataFormatString
=
"{0:yyyy/MM/dd}"
AllowFiltering
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"remain_work_qty"
EmptyDataText
=
""
HeaderText
=
"Remaining Hours"
SortExpression
=
"remain_work_qty"
UniqueName
=
"remain_work_qty"
DataType
=
"System.Decimal"
ReadOnly
=
"true"
AllowFiltering
=
"false"
DataFormatString
=
"{0:0}"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
SortExpression
=
"wbs_id"
HeaderText
=
"wbs_id"
HeaderButtonType
=
"TextButton"
DataField
=
"wbs_id"
Display
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"wbs_name"
HeaderText
=
"Work Package"
HeaderButtonType
=
"TextButton"
DataField
=
"wbs_name"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
This is how it is being bound:
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
if
(RadComboBox1.SelectedIndex != -1 && RadDropDownList1.SelectedIndex != -1)
{
string
projid = RadDropDownList1.SelectedValue;
string
cam = RadComboBox1.SelectedValue;
if
(!e.IsFromDetailTable)
{
RadGrid1.DataSource = GetDataTable(
"SELECT * FROM PrimaveraWbs WHERE proj_id = "
+ projid +
" and name = '"
+ cam +
"'"
);
}
}
}
public
DataTable GetDataTable(
string
query)
{
String ConnString = ConfigurationManager.ConnectionStrings[
"PSMSystemConnectionString"
].ConnectionString;
SqlConnection conn =
new
SqlConnection(ConnString);
SqlDataAdapter adapter =
new
SqlDataAdapter();
adapter.SelectCommand =
new
SqlCommand(query, conn);
DataTable myDataTable =
new
DataTable();
conn.Open();
try
{
adapter.Fill(myDataTable);
}
finally
{
conn.Close();
}
return
myDataTable;
}
protected
void
RadGrid1_DetailTableDataBind(
object
source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
switch
(e.DetailTableView.Name)
{
case
"Steps"
:
{
string
wbs_id = dataItem.GetDataKeyValue(
"wbs_id"
).ToString();
e.DetailTableView.DataSource = GetDataTable(
"SELECT * FROM PrimaveraTask WHERE wbs_id = "
+ wbs_id +
" ORDER BY task_code"
);
break
;
}
case
"StepDetails"
:
{
string
task_id = dataItem.GetDataKeyValue(
"task_id"
).ToString();
e.DetailTableView.DataSource = GetDataTable(
"SELECT * FROM PrimaveraSteps WHERE task_id = "
+ task_id +
""
);
break
;
}
}
}
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
string
acb = RadDropDownList1.SelectedText;
if
(RadComboBox1 !=
null
&& RadDropDownList1.SelectedIndex != -1)
{
if
(!Page.IsPostBack)
{
RadGrid1.MasterTableView.Items[0].Expanded =
true
;
RadGrid1.MasterTableView.Items[0].ChildItem.NestedTableViews[0].Items[0].Expanded =
true
;
}
}
}
How do I ensure that this message is not displayed when records do exist?
Thanks in advance,
Josh