[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 851
  • Last Modified:

gridview double click event

Hi! How to capture double click event of gridview?
0
PagodNaUtak
Asked:
PagodNaUtak
  • 4
  • 2
1 Solution
 
himanshutCommented:
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
 
PagodNaUtakAuthor Commented:
I am using ASP?
0
 
PagodNaUtakAuthor Commented:
ASP.NET I mean...
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
Mohit VijayCommented:
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
 
PagodNaUtakAuthor Commented:
Can you show some example code?
0
 
Mohit VijayCommented:
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
 
PagodNaUtakAuthor Commented:
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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now