This is a migrated thread and some comments may be shown as answers.

Dynamic reports created from sharepoing list - report display problem

1 Answer 68 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sss
Top achievements
Rank 1
sss asked on 20 Jan 2011, 12:52 AM
Hi,

I have been running a code to get the report columns dynamically from a sharepoint list.
I query the sharepoint list and get all the columns and rows in a datatable.
Next I use a code to generate the rows and columns dynamically in the report and assign the report to report viewer.

Here is the problem
When I get the column names the columns have encodings for space.  I clean the column names programatically and use the datatable to generate the columns and rows dynamically.  In this case the report does not show any controls and shows a blank rectangular box with red border.
The report fails to load if I do this cleaning process.

Earlier I had created the report using a static datatable and it worked well. I extended the code to use the exact column names from the sharepoint list.  If I directly use the datatable returned by the CAML query for getting all the columns, without cleaning the column heading text, the report shows the columns and rows. 

Please let me know if I'm doing something wrong by manipulating the data in the datatable to change the column name.

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 25 Jan 2011, 02:37 PM
Hi,

To manage the SharePoint encodings our suggestion is to use the following  methods:

/// <summary>Replace whitespaces with _x0020_ since that is was sharepoint expects.
/// </summary>
/// <param name="toEscape">The string to escape.</param>
/// <returns>The escaped string.</returns>
private string EscapeWhitespace(string toEscape)
{
    return toEscape.Replace(" ", "_x0020_");
}
 
/// <summary>Remoce special string from values returned from sharepoint.
/// </summary>
/// <param name="toUnescape">The string to unescape.</param>
/// <returns>The unescaped string.</returns>
private string UnescapeWhitespace(string toUnescape)
{
    string result = toUnescape.Replace("_x0020_", " ");
 
    // For now just replace remove unknown escape sequences.
    Regex regex = new Regex("_x[0-9a-f]{4}_");
    result = regex.Replace(result, string.Empty);
 
    // Also replace semicolon.
    result = result.Replace(";", string.Empty);
 
    // And the '#' character
    result = result.Replace("#", string.Empty);
 
    return result.Trim();
}

Another option would be to map the columns' names as explained in the Walkthrough: Mapping Data Source Tables to Dataset Tables msdn article.

Best wishes,
Peter
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
Tags
General Discussions
Asked by
sss
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or