Solved

Telerik RadTagCloud dynamic databinding...

Posted on 2011-03-07
3
819 Views
Last Modified: 2012-05-11
I have this code to fill the TagCloud control, but I don't know how can I set the NavigateUrl to a field which is not contained in database, something like ("~/Postbackpage.aspx?Make=Audi") ...for each tag there will be a different querystring for the NavigateUrlField.

protected void BindTagCloudToDataTable(RadTagCloud cloud) 
    { 
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SpecsConnectionString"].ConnectionString); 
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT [Make],count(*) AS [Weight] FROM [VehicleSpecs] group by [Make] ORDER BY [Make]", con); 
        DataTable links = new DataTable(); 
        adapter.Fill(links); 
  
        cloud.DataTextField = "Make"; 
        cloud.DataWeightField = "Weight"; 
        cloud.DataNavigateUrlField = "NavigateUrl"; 
        cloud.DataSource = links; 
        cloud.DataBind(); 
    }

Open in new window

0
Comment
Question by:evo_x
  • 2
3 Comments
 
LVL 2

Expert Comment

by:grossac
ID: 35062063
I haven't use the TagCloud but I would think that you can do something like this:

protected void BindTagCloudToDataTable(RadTagCloud cloud) 
    { 
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SpecsConnectionString"].ConnectionString); 
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT [Make],count(*) AS [Weight] FROM [VehicleSpecs] group by [Make] ORDER BY [Make]", con); 
        DataTable links = new DataTable(); 
        adapter.Fill(links); 
  
        cloud.DataTextField = "Make"; 
        cloud.DataWeightField = "Weight"; 
        cloud.DataNavigateUrlField = "/PostBackPage.aspx?Make=" + "Make"
        cloud.DataSource = links; 
        cloud.DataBind(); 
    } 

Open in new window


With "Make" being the make text from the data adapter

Just a guess.

http://www.telerik.com/help/aspnet-ajax/tagclouddatabinding.html

0
 
LVL 2

Author Comment

by:evo_x
ID: 35062109
This does not work, I get this error:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name '/PostBackPage'.
0
 
LVL 2

Accepted Solution

by:
grossac earned 500 total points
ID: 35062334
I didn't test it before, try this...

protected void BindTagCloudToDataTable(RadTagCloud cloud) 
    { 
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SpecsConnectionString"].ConnectionString); 
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT [Make],count(*) AS [Weight] FROM [VehicleSpecs] group by [Make] ORDER BY [Make]", con); 
        DataTable links = new DataTable(); 
        adapter.Fill(links); 
  
        cloud.DataTextField = "Make"; 
        cloud.DataWeightField = "Weight"; 
        cloud.DataSource = links; 
        cloud.DataBind(); 
    } 

            foreach (RadTagCloudItem item in cloud.Items)
            {
                item.NavigateUrl = "/PostBackPage.aspx?Make=" + item.Text;
            }

Open in new window

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now