Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 839
  • Last Modified:

Telerik RadTagCloud dynamic databinding...

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
evo_x
Asked:
evo_x
  • 2
1 Solution
 
grossacCommented:
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
 
evo_xAuthor Commented:
This does not work, I get this error:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name '/PostBackPage'.
0
 
grossacCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now