Proactivation
asked on
Selecting a Gridview row
I'm able to highlight a Gridview row when clicking on it by inserting client-side Javascript, but what I need to do is simulate clicking the Select button by clicking anywhere in a row, preferably without a visible Select button. Any ideas?
sorry
e.Row.Attributes.Add("oncl ick", "this.BackColor=Red")
e.Row.Attributes.Add("oncl
ASKER
Let me explain what I'm trying to do. I have a gridview linked to a detailsview as master/detail. If I enable Select buttons, clicking on one will populate the detailsview with the record I've just selected. The thing is I don't want select buttons, I want to just click on a row.
Hi Proactivation,
This is a good question... I'll be very interested in what the final outcome becomes. In my thinking there are two approachs to accomplish this task.
1) Have a Submit button for each row. I believe you could make the button hidden, but it's important that it exists, so you can use it to launch a click() event. Basically you would add a JavaScript onClick event for the row that would execute the submit button for that row. If you knew which control index it was, you could do something like:
e.Row.Attributes.Add("onCl ick", "document.getElementById(' " & e.Row.Cells(0).Controls(3) .ClientID & "').click();")
There are probably a variety of ways to accomplish this first idea.
2) You launch the __doPostBack(eventTarget, eventArgument) yourself in the JavaScript onClick event. To me, this is less clean, but might be a viable solution if all else fails.
Let me know what you think...
-- Jason
This is a good question... I'll be very interested in what the final outcome becomes. In my thinking there are two approachs to accomplish this task.
1) Have a Submit button for each row. I believe you could make the button hidden, but it's important that it exists, so you can use it to launch a click() event. Basically you would add a JavaScript onClick event for the row that would execute the submit button for that row. If you knew which control index it was, you could do something like:
e.Row.Attributes.Add("onCl
There are probably a variety of ways to accomplish this first idea.
2) You launch the __doPostBack(eventTarget, eventArgument) yourself in the JavaScript onClick event. To me, this is less clean, but might be a viable solution if all else fails.
Let me know what you think...
-- Jason
ASKER
Hi Jason
Interesting ideas! I've managed to get it going using the "messy" 2nd method, but I'd still like to get it going using proper events. It looks like there's a useful MouseUp event and Select method on Datagrids, but I can't find the equivalent for Gridviews. Thanks for helping me get this far.
Interesting ideas! I've managed to get it going using the "messy" 2nd method, but I'd still like to get it going using proper events. It looks like there's a useful MouseUp event and Select method on Datagrids, but I can't find the equivalent for Gridviews. Thanks for helping me get this far.
Proactivation,
When I get some time tomorrow I'll play around with it (I would like this functionality myself). I'll let you know what I find out. I'm glad to hear you got it going using any method... ;)
-- Jason
When I get some time tomorrow I'll play around with it (I would like this functionality myself). I'll let you know what I find out. I'm glad to hear you got it going using any method... ;)
-- Jason
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow, two solutions for the price of one! It's a shame they're both workarounds for the apparent lack of suitable events, but I've got a feeling I'll be using this one quite a bit in future. Thanks - you've been great!
Note for the googlers: Don't forget to add CommandName="Select" to the button definition above so it knows it's a select button.
Note for the googlers: Don't forget to add CommandName="Select" to the button definition above so it knows it's a select button.
"It's a shame they're both workarounds for the apparent lack of suitable events"
Agreed! For a product that is suposed to support newbies without having to know code I am somewhat miffed by VWD's lack of fundamental support...
Agreed! For a product that is suposed to support newbies without having to know code I am somewhat miffed by VWD's lack of fundamental support...
e.Row.Attributes.Add("Back