Hi All,
I am just testing radmenu as per the sample code provided by telerik
http://www.telerik.com/help/aspnet-ajax/menu-datatable-view.html
i have copied each and every line from the above url, but when i say RadMenu1.DataSource = CreateTestTable();
it throws error saying Object reference not set to an instance of an object.
i have pasted my code below for your reference.
your help greatly appreciated..awaiting your reponses..
Regards,
Praveen
I am just testing radmenu as per the sample code provided by telerik
http://www.telerik.com/help/aspnet-ajax/menu-datatable-view.html
i have copied each and every line from the above url, but when i say RadMenu1.DataSource = CreateTestTable();
it throws error saying Object reference not set to an instance of an object.
i have pasted my code below for your reference.
<
telerik:RadMenu
runat
=
"server"
ID
=
"RadMenu1"
Style
=
"z-index: 3"
EnableRoundedCorners
=
"true"
EnableShadows
=
"true"
EnableTextHTMLEncoding
=
"true"
>
</
telerik:RadMenu
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
FillRadMenu();
}
}
protected
void
FillRadMenu()
{
RadMenu1.DataSource = CreateTestTable();
RadMenu1.DataFieldID =
"ID"
;
RadMenu1.DataFieldParentID =
"ParentID"
;
RadMenu1.DataTextField =
"Text"
;
RadMenu1.DataValueField =
"ID"
;
RadMenu1.DataNavigateUrlField =
"URL"
;
RadMenu1.DataBind();
}
private
DataTable CreateTestTable()
{
DataTable table =
new
DataTable();
table.Columns.Add(
"ID"
);
table.Columns.Add(
"ParentID"
);
table.Columns.Add(
"Text"
);
table.Columns.Add(
"URL"
);
table.Columns.Add(
"Tooltip"
);
table.Rows.Add(
new
string
[] {
"1"
,
null
,
"root 1"
,
"root1.aspx"
,
"root 1 tooltip"
});
table.Rows.Add(
new
string
[] {
"2"
,
null
,
"root 2"
,
"root2.aspx"
,
"root 1 tooltip"
});
table.Rows.Add(
new
string
[] {
"3"
,
"1"
,
"child 1.1"
,
"child11.aspx"
,
"child 1.1 tooltip"
});
table.Rows.Add(
new
string
[] {
"4"
,
"1"
,
"child 1.2"
,
"child12.aspx"
,
"child 1.2 tooltip"
});
table.Rows.Add(
new
string
[] {
"5"
,
"1"
,
"child 1.3"
,
"child13.aspx"
,
"child 1.3 tooltip"
});
table.Rows.Add(
new
string
[] {
"6"
,
"5"
,
"child 1.3.1"
,
"child131.aspx"
,
"child 1.3.1 tooltip"
});
table.Rows.Add(
new
string
[] {
"7"
,
"5"
,
"child 1.3.2"
,
"child132.aspx"
,
"child 1.3.2 tooltip"
});
table.Rows.Add(
new
string
[] {
"8"
,
"5"
,
"child 1.3.3"
,
"child133.aspx"
,
"child 1.3.3 tooltip"
});
return
table;
}
your help greatly appreciated..awaiting your reponses..
Regards,
Praveen