?
Solved

gridview double click event

Posted on 2010-09-02
7
Medium Priority
?
844 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

764 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