jknj72
asked on
Gridview selected row
When I click the row it looks like its selected but when I move mouse away it goes away. Im trying to keep the row selected when I click but I already have an onclick attribute, which I need to keep, so Im trying to figure out another way to do it. Here is my RowDataBound. I have the color changing when I do mouseover and mouseout but is there another attribute I could use that will keep the selected row color?
Thanks
-JK
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes("onclick") = Page.ClientScript.GetPostBackClientHyperlink(myGridview, e.Row.Cells(1).Text & "|" & e.Row.Cells(0).Text & "|" & e.Row.Cells(2).Text)
e.Row.Attributes("onmouseover") = "this.style.backgroundColor='blanchedalmond';"
e.Row.Attributes("onmouseout") = "this.style.backgroundColor='white';"
end if
Thanks
-JK
ASKER
Id be happy to do that but what is the function going to look like? I cant figure out how to do it?
Something like this:
And you would add the function to your event instead of the action you currently have there...
public void MyOnClickFunction(object sender, EventArgs e)
{
//do multiple things
}
And you would add the function to your event instead of the action you currently have there...
e.Row.Attributes("onclick") = MyOnClickFunction;
ASKER
I cant get rid of the current onclick I have in my RowDataBound. I am using those values in my Postback to do other things I need. Are you saying to use onclick again to call a function to get my row selected? Can I use onclick attribute twice for different things?
All Im looking to do is select a row?
All Im looking to do is select a row?
ASKER
still looking to select a gridview row...anyone?? anyone?? Bueller??
I'm saying you should keep your onclick, but direct it to a function instead of your one line of code. Put all of your code in the function, perhaps with control flow (if / then statements) to determine whether conditions are appropriate to execute particular code.
ASKER
ok Ive done this and now for the big question....how do I change the backgroundcolor????? I tried e.row.backcolor = color.yellow but it didnt work. Ill keep trying to get this done but hopefully youll respond so I can put this to bed...THANK YOU!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank and sorry so late
e.Row.Attributes("onclick"