Solved

Telerik RadTagCloud dynamic databinding...

Posted on 2011-03-07
3
833 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

627 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