I am binding my data in a datatable and then bind that datatable into a datagrid. I want that some rows of the datatable should be highlighted with some color. How can we do that from code-behind?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to hook into the ItemDataBound event of the DataGrid, in order to dynamically set the properties you desire.
On your HTML, set the OnItemDataBound attribue of the DataGrid to a server-side event.
Then wire-up the server-side event handler:
You could then flip the colors based on the ListItemType enumeration: