Spread for ASP.NET 10 Product Documentation
DataItemDataField Property
Example 


Gets or sets the item data field of the data source of the tag cloud.
Syntax
'Declaration
 
Public Property DataItemDataField As String
'Usage
 
Dim instance As TagCloudCellType
Dim value As String
 
instance.DataItemDataField = value
 
value = instance.DataItemDataField
public string DataItemDataField {get; set;}

Property Value

String containing the item data
Remarks

If the DataDisplayTextField is a non-empty string, the DataDisplayTextField will be used to display the text for the cloud item. If the DataDisplayTextField property is null or empty string, the DataTextField will be used to display the text for the cloud item.

If the DataDisplayTextField property is used, the DataTextFormatString property will not be used. If the DataTextField property is used, the DataTextFormatString will be used to format the string to be displayed.

The DataItemDataField property is used to associate a value with a cloud item.

Example
This example binds the cell.
private DataSet CreateData()
{
    DataSet ds = new DataSet();
    DataTable dt = new DataTable();
    dt.Columns.Add(new DataColumn("ID", Type.GetType("System.Int32")));
    dt.Columns.Add(new DataColumn("Keyword", Type.GetType("System.String")));
    dt.Columns.Add(new DataColumn("Weight", Type.GetType("System.Int32")));

    dt.Rows.Add(new object[] { 1, ".net", 52 });
    dt.Rows.Add(new object[] { 2, "ajax", 22 });
    dt.Rows.Add(new object[] { 3, "css", 34 });

    ds.Tables.Add(dt);
    return ds;
} 
protected void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack) return;

    TagCloudCellType tcloud = new TagCloudCellType();
    tcloud.DataSource = CreateData();
    tcloud.DataDisplayTextField = "Keyword";
    tcloud.DataHrefField = "Keyword";
    tcloud.DataHrefFormatString = "http://msdn.microsoft.com/en-us/library/Tags-Cloud.aspx?tag={0}";
    tcloud.DataWeightField = "Weight";
    tcloud.DataTitleField = "Weight";
    tcloud.DataTitleFormatString = "{0} item(s) tagged";
    tcloud.DataItemDataField = "ID";

    FpSpread1.Sheets[0].Cells[1, 1].CellType = tcloud; 
}
protected void Button1_Click(object sender, EventArgs e)
{
    TagCloudCellType tc = FpSpread1.Sheets[0].GetCellType(1, 1) as TagCloudCellType;
    foreach (TagCloudItem ci in tc.TagCloudItems)
    {
        // get the ItemData value associated to the cloud item 
        System.Diagnostics.Debug.WriteLine(string.Format("DisplayText:{0} , ItemValue:{1}", ci.DisplayText, ci.ItemData));
    } 
}
Private Function CreateData() As DataSet
    Dim ds As New DataSet
    Dim dt As New DataTable
    dt.Columns.Add(New DataColumn("ID", Type.GetType("System.Int32")))
    dt.Columns.Add(New DataColumn("Keyword", Type.GetType("System.String")))
    dt.Columns.Add(New DataColumn("Weight", Type.GetType("System.Int32")))

    dt.Rows.Add(New Object() {1, ".net", 52})
    dt.Rows.Add(New Object() {2, "ajax", 22})
    dt.Rows.Add(New Object() {3, "css", 34})

    ds.Tables.Add(dt)
    Return ds
End Function

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If IsPostBack Then Return

    Dim tcloud As New TagCloudCellType
    tcloud.DataSource = CreateData()
    tcloud.DataDisplayTextField = "Keyword"
    tcloud.DataHrefField = "Keyword"
    tcloud.DataHrefFormatString = "http://msdn.microsoft.com/en-us/library/Tags-Cloud.aspx?tag={0}"
    tcloud.DataWeightField = "Weight"
    tcloud.DataTitleField = "Weight"
    tcloud.DataTitleFormatString = "{0} item(s) tagged"
    tcloud.DataItemDataField = "ID"

    FpSpread1.Sheets(0).Cells(1, 1).CellType = tcloud
End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim tc As TagCloudCellType = FpSpread1.Sheets(0).GetCellType(1, 1)
    For Each ci As TagCloudItem In tc.TagCloudItems
        ' get the ItemData value associated to the cloud item
        System.Diagnostics.Debug.WriteLine(String.Format("DisplayText:{0} , ItemValue:{1}", ci.DisplayText, ci.ItemData))
    Next
End Sub
Requirements

Target Platforms: Windows 7, Windows 8, Windows 10, Windows Vista, Windows Server 2003, Windows Server 2008, Windows Server 2012, Windows XP Professional

See Also

Reference

TagCloudCellType Class
TagCloudCellType Members

 

 


Copyright © GrapeCity, inc. All rights reserved.