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

String Escape Characters added to DataKeyValues

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cliff
Top achievements
Rank 1
Cliff asked on 01 Nov 2010, 09:46 PM
I am working with a datasource that uses a 5 character code as the fileid & PK. This code can contain any printable character, so I have some fileid(s) that shape up like this: AAA/>, AAA:/, etc.

In RadGrid, I have added this field to the DataKeyFields and access it in grid_itemCreated() to build a javascript link used in a button column.

Here is the problem, the FileID is 'AAA/>' but the code below extracts the fileid from the keyvalue as 'AAA//>'
and causes a "no records found" since the primary key has an extra / in it.

I cannot locate the place where this / is being added nor eliminate it on extract, any ideas?
protected void dg_results_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            HyperLink editLink = (HyperLink)e.Item.FindControl("EditLink");
            editLink.Attributes["href"] = "#";
            editLink.Attributes["onclick"] = String.Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["FileId"], e.Item.ItemIndex);
                 }
    }

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 05 Nov 2010, 08:49 AM
Hi Cliff,

What about modifing the string before you pass it to the javascript method? If, for example you have a string with value "char\\" the following code would replace the unneded '\' only in case the length of the string is 6 (an escaping char is appended):
if (str.Length > 5 && str.IndexOf("//") != -1)
  {
      str = str.Remove(str.IndexOf("//"), 0);
  }


All the best,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Cliff
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or