Can't get SelectedItemStyle to work with DataGrid's TemplateColumn setups.

Can't get SelectedItemStyle to work with DataGrid's TemplateColumn setups.

Post by Lenar » Mon, 12 May 2003 18:16:18



How does one make the SelectedItemStyle CssClass apply if using a TemplateColumn to "select" a row?  For example:

<asp:TemplateColumn >
    <ItemTemplate>
        <asp:RadioButton Runat="server" AutoPostBack="True" GroupName="Select" OnCheckedChanged="Selection_Click" ID="Select"></asp:RadioButton>
    </ItemTemplate>
</asp:TemplateColumn>

I've even tried forcing a row to a particular background color in the OnCheckedChanged event but no luck.  What am I missing?  ViewState is turned on and have the IsPostBack check in place in the Page_Load.

Thanks.

--Lenard

 
 
 

Can't get SelectedItemStyle to work with DataGrid's TemplateColumn setups.

Post by Scott Mitchell [MVP » Tue, 13 May 2003 03:39:40


Lenard, are you setting the SelectedIndex property of the DataGrid to the
selected row in the Selection_Click event handler?

--

    Scott Mitchell

    http://www.4GuysFromRolla.com
    http://www.ASPFAQs.com
    http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!


How does one make the SelectedItemStyle CssClass apply if using a
TemplateColumn to "select" a row?  For example:

<asp:TemplateColumn >
    <ItemTemplate>
        <asp:RadioButton Runat="server" AutoPostBack="True"
GroupName="Select" OnCheckedChanged="Selection_Click"
ID="Select"></asp:RadioButton>
    </ItemTemplate>
</asp:TemplateColumn>

I've even tried forcing a row to a particular background color in the
OnCheckedChanged event but no luck.  What am I missing?  ViewState is
turned on and have the IsPostBack check in place in the Page_Load.

Thanks.

--Lenard

 
 
 

Can't get SelectedItemStyle to work with DataGrid's TemplateColumn setups.

Post by Lenar » Tue, 13 May 2003 11:42:36


Hi Scott,

Yes, I had tried your idea.  The good news is.....the problem was in my stupid stylesheet.  
I had the following defined.  

A, BODY, TD
{
    font-family:Tahoma,Arial,Geneva,Helvetica,Sans-Serif;
    font-weight:normal;
    color:black;
    font-size:12px;
    background-color:transparent;

Quote:}

At first glance it looks OK.....but that "TD" was overriding all my DataGrid's Style-CssClass tags.  Take it out and all is fine.

Thanks for responding to my post, Scott.

--Lenard