All Products
Demos
Pricing
Services
Blogs
Docs & Support
Search
Shopping cart
Login
Contact Us
Get A Free Trial
close mobile menu
Telerik Forums
/
UI for ASP.NET AJAX Forum
/
Menu
/
how to get attribute
Cancel
Telerik UI for ASP.NET AJAX
Resources
Buy
Try
Feed for this thread
4 posts, 1 answers
David Blok
42 posts
Member since:
Nov 2009
Posted 03 Dec 2009
Link to this post
How can i get a attribute from the database ?
I see in the manuels for manual custom attributes but none from a database.
Database bind :
Dim
adapter
As
New
SqlDataAdapter(
"SELECT * FROM TblPages"
, _
ConfigurationManager.ConnectionStrings(
"Varodb"
).ConnectionString)
Dim
Menu
As
New
DataSet()
adapter.Fill(Menu)
RadMenu1.DataTextField =
"Pagename"
RadMenu1.DataFieldID =
"ID"
RadMenu1.DataFieldParentID =
"PageID"
RadMenu1.DataSource = Menu
RadMenu1.DataBind()
Call
Protected
Sub
Click(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.RadMenuEventArgs)
Label1.Text =
"ItemClick: "
+ e.Item.Text
End
Sub
How can i Call the ID field on the database ?
Answer
Shinu
17764 posts
Member since:
Mar 2007
Posted 03 Dec 2009
Link to this post
Hi David Blok,
Here is the example that I tried to add the
Custom Attribute
from database, and its working fine for me. Give a try with following code and see whether it helps.
CS:
protected
void
RadMenu1_ItemDataBound(
object
sender, Telerik.Web.UI.RadMenuEventArgs e)
{
DataRowView dataSourceRow = (DataRowView)e.Item.DataItem;
//set custom attributes from the datasource
e.Item.Attributes[
"Address"
] = dataSourceRow[
"Address"
].ToString();
}
protected
void
RadMenu1_ItemClick(
object
sender, RadMenuEventArgs e)
{
String add= RadMenu1.SelectedItem.Attributes[
"Address"
];
Response.Write(add);
}
-Shinu.
David Blok
42 posts
Member since:
Nov 2009
Posted 04 Dec 2009
Link to this post
Do you have a VB code for that ?
David Blok
42 posts
Member since:
Nov 2009
Posted 04 Dec 2009
Link to this post
i found the right code based on your C# code
thanks :)
Back to Top
Close