Solved

gridview double click event

Posted on 2010-09-02
7
843 Views
Last Modified: 2013-12-17
Hi! How to capture double click event of gridview?
0
Comment
Question by:PagodNaUtak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 10

Expert Comment

by:himanshut
ID: 33593110
Handles Double click event:
string variable;
 
        private void dataGridView1_CellMouseDoubleClick( object sender, DataGridViewCellMouseEventArgs e )
        {
            variable = dataGridView1[e.ColumnIndex,e.RowIndex].Value ;
        }

Open in new window

0
 
LVL 8

Author Comment

by:PagodNaUtak
ID: 33593231
I am using ASP?
0
 
LVL 8

Author Comment

by:PagodNaUtak
ID: 33593232
ASP.NET I mean...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:Mohit Vijay
ID: 33593674
You can use JavaScript.

write ondblclick event of javascript.

in this ondblclick of javascript you can click a button using JavaScript code like

document.getElementById('YourButtonId').click();


on click of this button, you can catch in your code.
0
 
LVL 8

Author Comment

by:PagodNaUtak
ID: 33593739
Can you show some example code?
0
 
LVL 8

Expert Comment

by:Mohit Vijay
ID: 33593764
ok

place a button on you asp.net page. set is visibility:hidden (style), assume its name/id is "yourbutton"

with your gridview control write

ondblclick="javascript:Catchdblclickevent();"


write a javascript function in script tag for javascript

function Catchdblclickevent()
{
document.getElementById('yourbutton').click();
}

Now this click event will behave same as user clicked on it, so hopefully you can trap it?

Is above sample ok?



0
 
LVL 8

Accepted Solution

by:
PagodNaUtak earned 0 total points
ID: 33593821
Here is myCode, I did it... :)
 protected override void OnInit(System.EventArgs e)
        {
            try
            {
                base.OnInit(e);
                this.gdviewApplicants.RowCommand += new GridViewCommandEventHandler(gdviewApplicants_RowCommand);
                this.gdviewApplicants.RowEditing += new GridViewEditEventHandler(gdviewApplicants_RowEditing);
                this.gdviewApplicants.RowDataBound += new GridViewRowEventHandler(gdviewApplicants_RowDataBound);
           
            }
            catch (System.Exception ex)
            { this.HandleException(ex); }
        }

protected void gdviewApplicants_RowEditing(Object sender, GridViewEditEventArgs e)
        {


        }

        protected void gdviewApplicants_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int selectIndex = int.Parse(e.CommandArgument.ToString());
            
            String commandName = e.CommandName;
            if (commandName == "Edit")
            {
                int ID = Convert.ToInt32(gdviewApplicants.Rows[Convert.ToInt32(e.CommandArgument)].Cells[1].Text);
                
            }


        }

        protected void gdviewApplicants_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            // 
        }
 

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question