Applying a style to a bound column

U

UJ

How do you apply a css style to a bound column? I've tried the following
code:

<asp:BoundColumn DataField="CompanyName" SortExpression="CompanyName"
HeaderText="Company" headerimageurl="../images/colcompany.gif" >
<ItemStyle cssclass='<%# SelectCellStyle(Container.DataItem("Selected"))
%>'></ItemStyle>
</asp:BoundColumn>


and get the error message BC30676: 'DataBinding' is not an event of
'System.Web.UI.WebControls.TableItemStyle'.

So how do I apply the style to the bound column?

TIA.
 
P

Phillip Williams

Try using the ItemDataBound event instead. Your code might look like that:
Sub DataGrid1_Created(ByVal sender As Object, ByVal e As
DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
e.Item.CssClass = CType(e.Item.DataItem, DataRowView).Row("Selected")
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top