Ejemplo n.º 1
0
        public static void MakeFullGridRowClickable(GridViewRow row, ClientScriptManager clientScriptManager)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                // Get the LinkButton control in the first cell

                LinkButton _singleClickButton = (LinkButton)row.Cells[0].Controls[0];
                // Get the javascript which is assigned to this LinkButton

                string _jsSingle =
                clientScriptManager.GetPostBackClientHyperlink(_singleClickButton, "");

                // To prevent the first click from posting back immediately
                // (therefore giving the user a chance to double click)
                // pause the postbackfor 300 milliseconds by
                // wrapping the postback command in a setTimeout

                _jsSingle = _jsSingle.Insert(11, "setTimeout(\"");
                _jsSingle += "\", 300)";

                // Add this javascript to the onclick Attribute of the row
                row.Attributes["onclick"] = _jsSingle;

                // Get the LinkButton control in the second cell
                LinkButton _doubleClickButton = (LinkButton)row.Cells[1].Controls[0];

                // Get the javascript which is assigned to this LinkButton
                string _jsDouble =
                clientScriptManager.GetPostBackClientHyperlink(_doubleClickButton, "");

                // Add this javascript to the ondblclick Attribute of the row
                row.Attributes["ondblclick"] = _jsDouble;
            }
        }