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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Asp.net Datagrid Template Columns

  • 10-06-2004 9: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