Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Asp.net Datagrid Template Columns

  • 10-06-2004 10:53AM
    #1
    Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭


    Folks,

    I have an asp.net page displaying data in a datagrid. One of these columns is a template column that has a textbox in the ItemTemplate (not the edit item template) called txtTemplate. The datagrid rows use alternating colours and I want to bind the BackColor property of txtTemplate to the BackColor of the row.

    I've tried to do this through code to no avail. Does anybody know the Custom Binding Expression syntax for something like this?


    Cheers
    E.P.


Comments

  • Registered Users, Registered Users 2 Posts: 640 ✭✭✭Kernel32


    Thats a very good question. As far as I can see you can't databind using databinder.eval(), but maybe someone else sees a way you can. For problems like this I usually end up going to the ItemDataBound event. It fires for each row as the grid binds and you can do custom formatting in there.


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Thats what I tried first. The BackColor property is empty for both the DataGridItemEvenArgs.Item object and DataGridItemEvenArgs.Item.Cells[index] in the ItemDataBound event.

    I'm guessing at the binding taking place before the items are formatted, I'll have to verify that, but Style.Count for Item and Item.Cells returns 0. The outputted HTML for the datagrid has style attributes so I reckon this is a good guess. I'll look further and let you know.


Advertisement