Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
690
Column Template from GridModel replicating across grid
posted

When applying a Template via the GridModel object like:

model.Columns[0].Template = "<a href=\"/blah/{{html id}}\">{{html name}}</a>";

OR

model.Columns[0].Template = "<a href=\"/blah/${html id}\">${name}</a>";

Results in all the OTHER columns in the grid displaying their {{html}} template (probably a default?)! For example:

Col1      Col2                      Col3                    Col4
Test    {{html Col2}}   {{html Col3}}  {{html Col4}}

What's going on here? Setting the templates for these columns has no effect.

Thanks, Tom

  • 690
    Verified Answer
    posted

    Right, it might have something to do with my column names having slashes in them...

    I managed to fix it by

    1. Assigning the full name (with slash characters) to the Caption
    2. Running myModel.DataBind()
    3. Set the Template on whatever column you want
    4. Loop through the Columns and assign model.Columns[i].HeaderText = tbl.Columns[model.Columns[i].Key].Caption