By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,681 Members | 1,864 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,681 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1"

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

Thanks for any help or information!

Feb 9 '07 #1
Share this Question
Share on Google+
1 Reply

P: n/a
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"
AllowSorting="True" AutoGenerateColumns="False"
DataSourceID="gridviewdatasource" DataKeyNames="Jobname">
<asp:Button ID="Run" SkinID="Button" Text="Run"
CommandArgument='<%#Eval("Jobname") %>'
Enabled='<%# Eval("Enabled")%>'
CommandName="Run" runat="server" />
<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.SelectedIndex = whaterver

Thanks again.

Feb 9 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.