Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Asp.net Datagrid Template Columns

Options
  • 10-06-2004 10:53am
    #1
    Registered Users 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 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 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