selecting row in gridview by clicking anywhere in row (not just on 'select' link)

Hi there-

I would like my gridview to behave such that a click anywhere in the (whole length of the) row would act just like clicking the "select" column link.

Anyone have any code or suggestions?


5/2/2006 9:20:54 PM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 10

You could use: ( but you would also need to disable event validation )


@ Page Language="VB" EnableEventValidation="false"%>

Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)

If e.Row.RowType = DataControlRowType.DataRow Then


"onclick", "javascript:__doPostBack('GridView1','select$" & e.Row.RowIndex & "')")

End If

End Sub
5/2/2006 11:13:51 PM

hmmm couldn't get that working...

but maybe it's easier to replace the text of a select commandfield with the text of a column value in the grid.

I will try to make that work - but let me know if you feel like showing some code for that scenario....thx a lot.

5/3/2006 2:40:18 PM

The line below didn't show up well on the last post, there are 2 undescores before the doPostBack and at the end after the last & there is a double quote, single quote,bracket,double quote and bracket.

e.RowAttributes.Add("onclick","javascript:__doPostBack('GridView1','select$" & e.Row.RowIndex & "')")

If you can't get that working I use a template field put a link button in it with the text bound to a field in the database and the command name as select. This does the same job as a select button but looks much better than a whole column of select buttons on the gridview.


5/3/2006 9:21:14 PM

your last example really helped me. thanks much!! using the template field and select.


5/3/2006 11:27:05 PM

Similar Artilces:

How to 'reset' the 'selected' status of a Gridview row?
Hi all, I have a girdview with selection enabled. BEsides, when the 'select' button is pressed, the row style will change. My problem is, when the user selected a row, then (for whatever reason) the gridview is refreshed (with a databind command), the selected row is still shown to be 'selected' (i.e. with the selectedRowStyle still applied) after the databind.  How can I make the selected row to become an ordinary/ non-selected row after databinding?Thanks Tony well for that u have to write a Client side function ..and stop the grid from doing post back.. u s...

First gridview's selected row doesn't update second gridview's objectdatasource
 HelloI got 2 gridviews on a page, each with its own ObjectDataSource. The first gridview fills itself just normally, no problem there. The second gridview needs to fill itself with other data, where the primary key is the primary key of the selected row of the first gridview.schematically:gridview1 row: IDfield, x, y, zrow: IDfield, x, y, z (-> this row is selected)row: IDfield, x, y, z gridview2 row:IDfield_of_selected_row_in_gridview1, a, b, c I tried to do this by configuring the ObjectDataSource behind gridview2 with a parameter pointing to gridview1.selectedValue. (by usin...

programmatically changing a row to a 'selected' row
Dear all, A Gridview row can assume the style defined in <selectedRowStyle> through a 'select' command field. My question is: if instead of using the 'select' button, I use a checkbox template.  I already know the row nr of which the checkbox had been checked (e.g. row 4)... but how can I change this row (row 4) to assume the same <selectedRowStyle> (ie. simulate the selection using a checkbox)?  Tony  you can write the logic in code behind file in grd__RowCommand(object sender, GridViewCommandEventArgs e) event You can set the selected row sty...

Maintaining the 'selected' row on a gridview when doing a postback
Hello,I have two gridviews on a page - doing master/detail. The second GridView is populated (and displayed) when the user selects a row in the master gridview. I have a command field on the master gridview:            <asp:CommandField ShowSelectButton="true" ButtonType="Button" SelectText="Select" /> On the child gridview - I have some radio buttons that have OnCheckedChanged="" defined. So when they get called the backpage (C#) handler gets called. This handler does a database update ...

'insert into ... select ...' error: select returns more than one row
Product: Sql Anywhere, Version I am using a 'insert into ... select ...' statement to insert multiple rows into a table however, I receive the following error when the statement is executed, Error: SELECT returns more than one row, SQLCODE = -185, ODBC 3 State = HY000. I am unsure what is incorrect with the statement. The statement used is: insert into ecs.tbl_resolutions_signatories (RESOLUTIONID, REFID) select @resolutionid as resolutionid, id as refid from ecs.tbl_shareholders where companyid = 7 and id in (select shareholderid from ecs.tbl_sharetrans...

Gridview paging enabled. Has checkbox to select the row . If user select the checkbox on one page and move to 2nd page to select the rows there also to export the selected rows to excel. But doing so
HiI am using Gridview and that has paging enabled. Using checkbox to select the particular row of the gridview to export the selected rows to the excel . Everything is working fine except for one case.Let user selected the "check" box for, five rows which user would like to export to excel (two of rows on page 1 of results and 3 of them on page 2 of results), however it only exports the 3 row details from page 2, because it seems to de-select the 2 rows from page 1 when I move to page 2 and vice versa. The code i am using is as :protected void BtnExcel_Click(object sender, EventArg...

Selecting a gridview row and keeping the last selected row in a gridview highlighted after mouse moves over a new row.
What is the best way to show a gridview row highlighted once selected and keep it highlighted once the mouse moves over a different row? Thanks, Steve hi,you can use <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="#FFFFFF" /> plz let me know if i misunderstood you Thanks for your help. One problem; however, is that after the row has been selected and I check the "grid.SelectedIndex" it has a value of -1 and not the index of the row that was selected on the grid. What do you recommend? Thanks, Steve hi, sorry i din...

Iwant to select a row and column in gridview with select radiobutton. but No checked change event.below put a button .if click that button to seleced row values will select
I want to select a row and column in gridview using radiobutton in gridview . if which radio button is select that row will select and i want that row column values in outside individual textboxes of next page.  but in that only single radiobutton will select and no post back="true" bcz iam not using checked change property. i inserted button below gridview. if i click the that selected row and columns values are stored into textboxes of next page im using this code .but im getting one column in that row. but i want all columns in that selected row so plz repla...

Using 'Take' to Restrict Rows on LinqDataSource (Similar to 'Select Top ...' in SQL)
Dear All  I am using Linq to pull out records from an SQL server table called 'News' with the LinqDataSource as follows:<asp:LinqDataSource ID="NewsByDateDS" runat="server" ContextTypeName="NewsDataContext" GroupBy="newsAddedOn" Select="new (Key, It as Items)" TableName="News" OrderBy="newsAddedOn DESC" OrderGroupsBy="Key DESC">  I need to add an extra bit of functionality so that it only pulls out the top 10 records. In SQL, it would of been 'SELECT TOP 10 ...' and I u...

[:'(] can't get the value of a cell from gridview selected row
Hi guys I made created a gridview that shows shopping cart items. this gridview uses storedprocedure that uses two parameter. (cartid=session.sessionid and productid=int) anyway, I would like to put row delete command and quantity update futures to it. I am using VWD and VB if any of you can send me some sample script will be greatly appriciated.   my biggest problem is that I do not know how to reach to selected row productid value thanks in advance Did you set the DataKeyNames in  your GridView? <asp:GridView ID="GridView1" DataKeyNames="int" .... (VB)

How to use GridView row's Key selected for Delete as select parameter for another datasource
I'm not sure if the subject title makes sense, but it wasn't too easy to describe what I'm trying to do in one sentence! When a user clicks on the delete link in a GridView row, I want to run a stored proc, using the Key of the selected record as the parameter for the stored proc. I then want to programatically access the result of the stored proc (it'll be an integer value) for code-behind use. I wrote out a few steps to help me figure out what I need to do: 1) Get the value of PersonnelID (the DataKey) from the selected row in the GridView2) Set that Perso...

I can't get value of control in the selected row of a Gridview
I'm trying to perform an update using a sqldatasource from a gridview after a selection is made from a dropdown and a linkbutton "lbnUpdate" is clicked. I assigned  "select" as the command name of the linkbutton so I was assuming that I could then reference the gridviews selected row from the code behind but I guess I made a bad assumption. During debug there is "nothing" in the variable I use to capture the gridview selected row. I will post what I have. If I set AutoGenereateSelect button to true I can get the SelectedIndexChanged event...

Direct 'Select' vs 'Select' from host variables
Hi all Question regarding what is bad regarding a select statement. I have a table contains 15 columns and I need to select all the 15 columns. My question is: what is the performance hit, if I take the column values into host variables and then select from them. The usual way is: 1. select all 15 columns in a select statement select column1, column2 ..... from tablename What I would like to do is: declare @column1 , @column 2 .... select @column1 = column1, @column2 = column2 ... from table select @column1, @column2 .... I need to pass the values of column...

Showing GridView's row containing textboxes (all textboxes of the row) yellow when one of the textboxes is selected.
I have a gridview where each row's cells contain textboxes (for providing I/O into the gridview) The problem I need to solve, I think, is with textboxes that make up the cells of the grid. When I select one of the textboxes that make up the cells of the gridview, then I want the whole row, each of the row's textboxes, to be highlighted in yellow showing that row as being selected. Thanks, Steve sholdorf: I have a gridview where each row's cells contain textboxes (for providing I/O into the gridview) The problem I need to solve, I think, is with textboxes that make up the ...

Web resources about - selecting row in gridview by clicking anywhere in row (not just on 'select' link) -

Resources last updated: 12/5/2015 11:16:51 AM