e.Row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(DirectCast(sender, System.Web.UI.Control), "Select$" + e.Row.RowIndex.ToString()))
Then on the RowCommand Event:
If e.CommandName = "Select" Then
GridView1.EditIndex = e.CommandArgument
End If
You can download a sample Visual Studio 2005 solution here
Update
---------------------------
Getting this error message?
Invalid postback or callback argument. Event validation is enabled using
If you don't want to set enable event validation to false then you can try the following:
Protected Overloads Overrides Sub Render(ByVal writer As HtmlTextWriter)
For i As Integer = 0 To Me.gv1.Rows.Count - 1
Page.ClientScript.RegisterForEventValidation(Me.gv1.UniqueID, "Select$" & i)
Next
MyBase.Render(writer)
End Sub
4 comments:
Your posting was very helpful! I'm a newbie and this so far is the easiest method that I have found.
Really neat skillz .....but I was not able to download the file...could u provide a working link for download....would be helpful..
That sweet. Just the kind of thing I was looking for. It chokes when your gridview is inside an AJAX updatepanel, but I'm sure I figure a work around.
If I get it, I'll put in pastebin, and post a link.
Thanks dude.
I rescind my above statement re it choking in update panel. It was my nubitude that was causing it to choke. It works just fine.
THANKS!
Post a Comment