I then wanted to use a query string in the menu for the url.... I was wanting to do something like this but it will not work.
<telerik:RadMenu ID="RadMenu1" Runat="server" DataFieldID="MapID"
DataFieldParentID="ParentID" DataNavigateUrlField='<%# Eval("Url", "?Url={0}") %>'
DataSourceID="LinqDataSource1" DataTextField="Title"
Skin="Telerik" Width="100%" >
basicly I just want the menu to postback to the default.aspx page where I have a details view.
somehing like this" default.aspx?Url=PageName
Any ideas?
Thanks
8 Answers, 1 is accepted
The DataNavigateUrlField helps identify the column from the database which contains the url of the items. So rather than using this property you can try setting the NavigateUrl for items in the ItemDataBound event of your RadMenu:
c#:
protected void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e) |
{ |
e.Item.NavigateUrl = "~/Default.aspx?Url=" + DataBinder.Eval(e.Item.DataItem, "PageName"); |
} |
Thanks
Princy.
Thanks again...
Hi
I have a similar problem; I am attempting to set the DataNavigationalUrlField like this:
DataNavigateUrlField="~/Default.aspx?Menuid={0}"
Unfortunately the url just shows this when clicked Default.aspx#
I have also tried this:
protected void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)
{
e.Item.NavigateUrl = "~/Default.aspx?Menuid={0}";
}
Hope someone can help
The DataNavigationalUrlField points to a column in your datasource which contains the URL.
You need to use the ItemDataBound event in your case:
protected
void
RadMenu1_ItemDataBound(
object
sender, RadMenuEventArgs e)
{
DataRowView row = (DataRowView)e.Item.DataItem;
e.Item.NavigateUrl =
"~/Default.aspx?Menuid="
+ row[
"menuID"
].ToString();
}
All the best,
Veselin Vasilev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Hi Thank you for the quick response.
Unfortunately this still hasn't corrected the problem. When I hover or click over the links the page just refreshes e.g Default.aspx#
I have pasted my code in below.
<
radM:RadMenu ID="RadMenu1" DataTextField="Text" runat="server" DataSourceID="SqlDataSource1" DataFieldID="MenuID" DataFieldParentID="ParentID" DefaultGroupSettings-ExpandDirection=Right SkinsPath="~/RadControls/Menu/Skins" Flow="Vertical" Skin="CssGrey" DataNavigateUrlField="RadMenu1_ItemDataBound">
</
radM:RadMenu>
code behind
public
partial class WHGC : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e)
{
DataRowView row = (DataRowView)e.Item.DataItem;
e.Item.NavigateUrl =
"~/Default.aspx?Menuid=" + row["menuID"].ToString();
}
}
Hope you can help.
Many Thanks
Hi Qball,
I believe Veselin was suggesting that you use the code in the ItemDataBound event of the RadMenu:
OnItemDataBound="RadMenu1_ItemDataBound" |
It looks like you put this instead:
DataNavigateUrlField="RadMenu1_ItemDataBound" |
Hope this helps,
Casey
Thanks Casey
That was it, all works great now.
Thank you both for all your help.
Hello,
Thank you Princy. Likewise this is what I was looking for.
I just have an issue that is raised which I'm not sure it can be resolved.
Currently I don't have a ParentID field in my db table and I'm about to add it so that I can include the DataFieldParentID capability.
Also, since I'm using the ID for the DataNavigationUrlField there will always be a value.
protected void RadMenu1_ItemDataBound(object sender, RadMenuEventArgs e) |
{ |
e.Item.NavigateUrl = "~/Page.aspx?Id=" + DataBinder.Eval(e.Item.DataItem, "ID"); |
} |
Problem I'm encountering is that if the items (ParentID) intent is to only be a text field without any navigation, the url is created anyways.
My thoughts are that the only thing I can do is add a UrlField (char(5)) in my db table and 'duplicate add or leave empty' the ID value to it and use it as the DataNavigationUrlField.
Before I make the necessary db changes, any alternative thoughts or ideas are appreciated.
Thank you in advance,
Ronnie