selected index row color


J

JohnE

The question is with a gridview. I have changed an asp:bound field with an
asp:templatefield using a linkbutton inside (source code is below). This is
the ID column that the user will see with it underline. They are
familiar/accustomed to seeing this and what it means and what they can do.
But, I also had the SELECT next to the row that when clicked the
SelectedIndexChanging event would turn the row as indicated in the
SelectedRowStyle of the gridview. The Select is gone in favor of adding real
estate back into the gridview.

<asp:TemplateField HeaderText="ID"
SortExpression="ChangeRequestID">
<ItemTemplate>
<asp:LinkButton ID="lbtnChangeRequestDetailView"
runat="server" ForeColor="Black" CommandName="Request"
Text='<%#
DataBinder.Eval(Container.DataItem,"ChangeRequestID") %>'

OnClick="lbtnChangeRequestDetailView_Click"
CommandArgument='<%#
DataBinder.Eval(Container.DataItem,"ChangeRequestID") %>' >
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

How can I get the row highlighted by using the above linkbutton and the
current SelectedRowStyle of the gridview?

.... John
 
Ad

Advertisements

M

Mark Rae [MVP]

How can I get the row highlighted by using the above linkbutton and the
current SelectedRowStyle of the gridview?

What does lbtnChangeRequestDetailView_Click contain?
 
J

JohnE

Mark Rae said:
What does lbtnChangeRequestDetailView_Click contain?

As of now, it contains only one line that says this is were the detail is
going. The original Select button used the following;

protected void gvwChangeRequestList_SelectedIndexChanging(object sender,
GridViewSelectEventArgs e)
{
if (gvwChangeRequestList.SelectedIndex == e.NewSelectedIndex)
{
e.Cancel = true;
gvwChangeRequestList.SelectedIndex = -1;
}
}

This worked with a toggling by highlighting the row when clicked and
unhighlighting when clicked again. Tried moving the above to the lbtn event
you mentioned but couldn't get it to work.
 
M

Mark Rae [MVP]

As of now, it contains only one line that says this is were the detail is
going.

Er, so unless I'm missing something, you've wired up the LinkButton to a
Click event which does nothing...?
 
Ad

Advertisements

J

JohnE

Mark Rae said:
Er, so unless I'm missing something, you've wired up the LinkButton to a
Click event which does nothing...?

So far, yes. But I placed it there so I would not forget about it. It is
two items away from being worked on going by the list of things to do. When
the linkbutton got added, I added the event with comments and why it was
needed.
 

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

Top