DataGrid and Htmlencode

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michal Raatz

    #1

    DataGrid and Htmlencode

    Welcome.
    I have a common problem with the datagrid: when the data source contains
    html tags (<script>docume nt.location.hre f='www.badsite. com'</script> for
    example) the page with the datagrid becomes unsafe. I have found two
    possible solutions in the net:
    - using template columns and HTMLEncode
    - using ItemCreated event of the datagrid
    Both method works but the grid grows drasticly. And when I have
    dynamicly created SQL query, used with AutoGenerateCol umns property the
    above methods do not apply.

    I think the better solution is extending the datagrid in such way, that
    the ServerHTML encode will be called on every bound column (without touching
    hyperlink , template, etc columns). The problem is that I have to little
    experience in writting controls to manage that. I don't know which methods
    should be ovverriden and how. I think, something like "CreateItem " or
    "InitializeItem " - but I'm totally mixed.
    Could you point me in the right direction? (absolutly don't want the
    ready code, I just need some ideas)

    Regards


Working...