1
Answer

Microsoft Report: Truncating Data Field Values

Photo of Carmen

Carmen

15y
5k
1

I'm populating a table on a microsoft report with a dataset I create in XML editor. the cells on my table contain:
=Fields!Name.Value
How do I truncate Field Values in cell? Do I truncate them in the XML editor or on the report? What would the syntax look like?
Thanks!

Answers (1)

0
Photo of Vulpes
NA 98.3k 1.5m 13y
Try this:

    using System.Xml.Linq;

    // ....

    string xml = "<data> <name1>Ramesh</name1> <name2>Kumar</name2> </data>";
    XElement data = XElement.Parse(xml);
    var dict = new Dictionary<string, string>();
    foreach (XElement child in data.Elements()) dict.Add(child.Name.ToString(), child.Value);

    // check it worked
    string temp = "";
    foreach (string key in dict.Keys) temp += String.Format("{0} : {1}\r\n", key, dict[key]);
    MessageBox.Show(temp);