Applying a style to a bound column

Discussion in 'ASP .Net Datagrid Control' started by UJ, May 19, 2005.

  1. UJ

    UJ Guest

    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.
     
    UJ, May 19, 2005
    #1
    1. Advertising

  2. 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

    --
    WEBSWAPP Development Inc.
    http://www.webswapp.com


    "UJ" wrote:

    > 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.
    >
    >
    >
     
    Phillip Williams, May 19, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John E.
    Replies:
    3
    Views:
    4,472
    masoud bayan
    Mar 25, 2005
  2. sunil panda

    Lower bound & Upper bound

    sunil panda, Dec 25, 2003, in forum: Java
    Replies:
    9
    Views:
    7,253
    thushara wijeratna
    Oct 7, 2008
  3. Ravichandran Mahalingam

    Bound Column or Template Column (w dAdapater?) in DataGrid

    Ravichandran Mahalingam, Jan 9, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    224
    Ravichandran Mahalingam
    Jan 9, 2004
  4. John E.

    Move bound column to right of dynamic column in datagrid?

    John E., Mar 24, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    233
    Elton Wang
    Mar 28, 2005
  5. TS
    Replies:
    3
    Views:
    409
    Walter Wang [MSFT]
    Aug 16, 2007
Loading...

Share This Page