I am using a GridView control in ASP.NET web form to display the data records. I want to handle the double click event of the row of the GridView. also I should get information which row is clicked.
4
votes
5 Answers
5
votes
Please refer to this brilliant post that will assist you with your problem http://www.codeproject.com/Articles/15677/Clickable-and-Double-Clickable-Rows-with-GridView
0
votes
Protected Sub GridView2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged
Dim row As GridViewRow = GridView1.SelectedRow
Dim i As Integer = 0
GridView1.Rows(row.RowIndex).BackColor = ColorTranslator.FromHtml("#A1DCF2")
MsgBox(doubleClick & " " & GridView1.SelectedIndex.ToString)
If doubleClick = GridView1.SelectedIndex.ToString Then
MsgBox("Yo")
End If
doubleClick = GridView1.SelectedIndex.ToString
End Sub
0
votes
Try this simple code I wrote. It works for me.
Protected Sub GridView2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridView1.SelectedIndexChanged
Dim row As GridViewRow = GridView1.SelectedRow
Dim i As Integer = 0
GridView1.Rows(row.RowIndex).BackColor = ColorTranslator.FromHtml("#A1DCF2")
MsgBox(doubleClick & " " & GridView1.SelectedIndex.ToString)
If doubleClick = GridView1.SelectedIndex.ToString Then
MsgBox("Yo")
End If
doubleClick = GridView1.SelectedIndex.ToString
End Sub
0
votes
After a lot of unsuccessful tries, I got it done using Jquery, this way:
$('html').on('click', ".wwdblclick", function (e) {
e.preventDefault;
return false;
});
$('html').on('dblclick', ".wwdblclick", function (e) {
var x = $(this).attr("href").replace("javascript:", "");
$(this).attr("ondblclick", x);
if (!(typeof $(this).attr("wwRunningDblclick") !== "undefined")) {
$(this).attr("wwRunningDblclick", "true");
$(this).trigger("dblclick");
}
else {
$(this).removeAttr("wwRunningDblclick");
}
});
Then just set the "wwdblclick" cssClass in your grid button command, like this:
<asp:LinkButton ID="lkbX" runat="server" Text="<i class=icon-minus-sign></i>" CssClass="wwdblclick" CommandName="action" CommandArgument='<%# Eval("id") %>' />
Cheers,