Solved

gridview double click event

Posted on 2010-09-02
7
841 Views
Last Modified: 2013-12-17
Hi! How to capture double click event of gridview?
0
Comment
Question by:PagodNaUtak
  • 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
Independent Software Vendors: 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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