Gridview selectedrowstyle-backcolor does not work when buttons selected??

J

jobs

I can't seem to get selectedrowstyle-backcolor to set the row
background color unless I force the selected index in the code behind.
When i select the ButtonField Run button it does set the background
color for the row. Is there another property I need to set to allow
selection for this to work?

</div>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
SelectedRowStyle-BackColor="lightcoral">
<Columns>

<asp:ButtonField Text="run" ButtonType="Button"
CommandName="run" />
<asp:CommandField ShowEditButton="True"
ShowDeleteButton="True"/>

Thanks for any help or information!
 
J

jobs

Following up on my own question.. I see there is a showselectcommand
that does work, but I'm trying to do several things here. I need to
select and highlight the row when select by another button that does
stuff, and I've had to place that button under a TemplateField because
I need evalutate bound data to determine whether to enable or not..
could not figure out how to do that under a buttonfield since it has
no enabled property nor does it allow bind or eval..

<asp:GridView SkinID="gridview" ID="rungridview" runat="server"
AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False"
SelectedRowStyle-BackColor="yellow"
DataSourceID="gridviewdatasource" DataKeyNames="Jobname">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Run" SkinID="Button" Text="Run"
CommandArgument='<%#Eval("Jobname") %>'
Enabled='<%# Eval("Enabled")%>'
CommandName="Run" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Schedule" HeaderText="Schedule"
SortExpression="Schedule" />

Also, wondering .. in the codebehind, under the rowcommand event, is
there any way that I get the index of the row for which the command
was selected? If so, i could then simply

Protected Sub PendingGridView_RowCommand(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles
rungridview.RowCommand
....
rungridview.SelectedIndex = whaterver

Thanks again.
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top