-
Nov 19th, 2012, 10:36 AM
#1
Thread Starter
Hyperactive Member
Select a row in gridview without select button/link
I want to select a row of gridview and display a DetailsView. There is issue of real estate on page so I do not want to use a select button. Please advise how can we achieve this?
Thanks
-
Nov 19th, 2012, 07:15 PM
#2
Re: Select a row in gridview without select button/link
I Will give you the opposite solution, figure out the one you want:
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Nov 20th, 2012, 09:34 PM
#3
Frenzied Member
Re: Select a row in gridview without select button/link
I usually make one or more of the fields a hyperlink and use that as my select to drill into a details page, e.g. if I have a list of projects, I make the project name a link (or button or whatever you want, just a clickable control that handles your Select code). Then in your RowDataBound you can do something like the following to make the link:
Code:
Protected Sub MyGridView_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles MyGridView.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim MyLinkButton As LinkButton = e.Row.FindControl("MyLinkButton")
MyLinkButton.PostBackUrl = "~\MyPage.aspx?ID=" & MyGridView.DataKeys(e.Row.RowIndex).Value
Last edited by SeanGrebey; Nov 20th, 2012 at 11:09 PM.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Nov 27th, 2012, 09:36 AM
#4
Hyperactive Member
Re: Select a row in gridview without select button/link
You can just use the row itself as a link. When the user mouses over the row, change the color (this will help alert them that the row itself is interactive). Have each row a hidden control with a unique ID. When the user clicks the row, your codebehind can determine the row number. Use that row number to get the corresponding hidden control. Then, use the ID from the hidden control to process the request from there.
if i was able to help, rate my post!
-
Nov 27th, 2012, 07:09 PM
#5
Re: Select a row in gridview without select button/link
It not mandatory but i think it would be better to get the gridview.Datakeys for determining the row.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Nov 28th, 2012, 04:40 AM
#6
Re: Select a row in gridview without select button/link
You can set the link/button commandArgument = datakey and use the grid.rowCommand event to get it. All these suggestions require viewstate on the grid if that's ok, I's the detailview is on the same page?
The problem with computers is their nature is pure logic. Just once I'd like my computer to do something deluded.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|