javascript - How to enable double and single click for GridView row in Asp.net c# -




i have gridview row in asp.net, single click event working on it
need add double click event on grid rows. how can that?

please me.

        protected void gridview1_rowdatabound(object sender, gridviewroweventargs e)                 {                     if (e.row.rowtype == datacontrolrowtype.datarow)                     {                         // linkbutton control in first cell                         linkbutton _singleclickbutton = (linkbutton)e.row.cells[0].controls[0];                         // javascript assigned linkbutton            string _jssingle = clientscript.getpostbackclienthyperlink(_singleclickbutton, "");                         // prevent first click posting                          // (therefore giving user chance double click) pause                          // postback 300 milliseconds using settimeout                         _jssingle = _jssingle.insert(11, "settimeout(\"");                         _jssingle += "\", 300)";                         // add javascript onclick attribute of row                         e.row.attributes["onclick"] = _jssingle;                          // linkbutton control in second cell                         linkbutton _doubleclickbutton = (linkbutton)e.row.cells[1].controls[0];                         // javascript assigned linkbutton                         string _jsdouble = clientscript.getpostbackclienthyperlink(_doubleclickbutton, "");                         // add javascript ondblclick attribute of row                         e.row.attributes["ondblclick"] = _jsdouble;                     }                 }                    protected void gridview1_rowcommand(object sender, gridviewcommandeventargs e)                 {                     gridview _gridview = (gridview)sender;                      // selected index , command name                     int _selectedindex = int.parse(e.commandargument.tostring());                     string _commandname = e.commandname;                      switch (_commandname)                     {                         case ("singleclick"):                             _gridview.selectedindex = _selectedindex;                             this.message.text += "single clicked gridview row @ index " + _selectedindex.tostring() + "<br />";                             break;                         case ("doubleclick"):                             response.write("<script type='text/javascript'>detailedresults=window.open('patient//patientdicomviewpage.aspx');</script>");                              // response.redirect("viewpatient.aspx");                             this.message.text += "double clicked gridview row @ index " + _selectedindex.tostring() + "<br />";                             break;                     }                 }       design of grid       <asp:gridview id="gridview1" runat="server" backcolor="white" bordercolor="#dedfde"                  borderstyle="none" borderwidth="1px" cellpadding="4" forecolor="black" gridlines="vertical"                  onrowdatabound="gridview1_rowdatabound" onrowcommand="gridview1_rowcommand">                 <footerstyle backcolor="#cccc99" />                 <columns>                                     <asp:buttonfield text="singleclick" commandname="singleclick" visible="false"/>                     <asp:buttonfield text="doubleclick" commandname="doubleclick" visible="false"/>                 </columns>                 <rowstyle backcolor="#f7f7de" />                 <headerstyle backcolor="#6b696b" font-bold="true" forecolor="white" />                 <selectedrowstyle backcolor="#ce5d5a" font-bold="true" forecolor="white" />                 <pagerstyle backcolor="#f7f7de" forecolor="black" horizontalalign="right" />                             <alternatingrowstyle backcolor="white" />             </asp:gridview> <asp:label id="message" runat="server" forecolor="red" font-bold="true"></asp:label>   




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -