Click here to Skip to main content
16,016,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to select a row on clicking anywhere on the row in grid view.

So i can capture the index of the Gridview.

I have used in Gridview RowDataBound

VB
If (e.Row.RowType = DataControlRowType.DataRow) Then
           e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand';this.style.textDecoration='underline';")
           e.Row.Attributes.Add("onmouseout", "this.style.textDecoration='none';")

           e.Row.Attributes.Add("onclick", ClientScript.GetPostBackClientHyperlink(Me.gvDrugs, "Select$" + e.Row.RowIndex.ToString()))
           Dim str As String
           str = e.Row.RowIndex.ToString()

while loading there is no problem..

When the Gridview is appeared and i click on the GridView row it throws exception

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. 


So i added In page Directive
VB
AutoEventWireup="false"  
EnableEventValidation="false"



But still getting the same error.

I want to capture the (id that comes from the database) on the click of the row in the grid


Can any one help me.


Thank you,
yashoda
[edit]Code blocks adde, some minor tweaks - OriginalGriff[/edit]
Posted
Updated 25-Mar-11 23:41pm
v3

1 solution

If you want to select full row on click any cell of the datagridview, you can do it very simply.

Click on the datagridview Go to its Properties and Set The SelectionMode to FullRowSelect.


Now full row will be selected instead of only header.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900