This is a migrated thread and some comments may be shown as answers.

how to get attribute

3 Answers 78 Views
Menu
This is a migrated thread and some comments may be shown as answers.
David Blok
Top achievements
Rank 1
David Blok asked on 03 Dec 2009, 02:09 PM
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 ObjectByVal e As Telerik.Web.UI.RadMenuEventArgs)  
        Label1.Text = "ItemClick: " + e.Item.Text  
    End Sub 

How can i Call the ID field on the database ?

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 03 Dec 2009, 03:03 PM
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.
0
David Blok
Top achievements
Rank 1
answered on 04 Dec 2009, 10:04 AM
Do you have a VB code for that ?
0
David Blok
Top achievements
Rank 1
answered on 04 Dec 2009, 10:18 AM
i found the right code based on your C# code

thanks :)
Tags
Menu
Asked by
David Blok
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
David Blok
Top achievements
Rank 1
Share this question
or