how to get attribute

4 posts, 1 answers
  1. David Blok
    David Blok avatar
    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 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 ?
  2. Answer
    Shinu
    Shinu avatar
    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.
  3. David Blok
    David Blok avatar
    42 posts
    Member since:
    Nov 2009

    Posted 04 Dec 2009 Link to this post

    Do you have a VB code for that ?
  4. David Blok
    David Blok avatar
    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