A0110 0 Newbie Poster
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton dblclkbtn = (LinkButton)e.Row.Cells[0].Controls[0];
            string _jsdbl = ClientScript.GetPostBackClientHyperlink(dblclkbtn, "");
            e.Row.Attributes["ondblclick"] += _jsdbl;
           // e.Row.Attributes.Add("ondblclick", "Javascript:__doPostBack('DoubleClick','" + e.Row.RowIndex + "');");
            string jsCommand = string.Format("__doPostBack('{0}','Edit${1}')",GridView1.ID, e.Row.RowIndex, GridView1.EditIndex);
                foreach (TableCell c in e.Row.Cells)
                {
                    if (c == e.Row.Cells[0])
                    {
                    }
                    else
                    {
                        c.Attributes["ondblclick"] = jsCommand;
                    }
                }


            }




        //if (e.Row.RowType == DataControlRowType.DataRow)
        //{
            if (list != null)
            {
                if (list.Contains(e.Row.Cells[2].Text))
                    e.Row.BackColor = Color.Yellow;
                else
                    e.Row.BackColor = Color.White;
            }

}





    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {

        if (e.CommandName == "DoubleClick")
        {
            int index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row = GridView1.Rows[index];
            GridViewEditEventArgs edit = new GridViewEditEventArgs(index);
            edit.NewEditIndex = index;
            object s=new object ();
            if (GridView1.Rows.Count> 0)
            {
                GridView1.EditIndex= edit.NewEditIndex;
            }
            GridView1_RowEditing(s, edit);

            // string msg = row.Cells[2].Text;
            if (list != null)
            {
                if (list.Contains(row.Cells[2].Text))
                {
                    list.Remove(row.Cells[2].Text);
                    row.BackColor = System.Drawing.Color.White;
                }
                else
                {
                    list.Add(row.Cells[2].Text);
                    row.BackColor = System.Drawing.Color.Yellow;
                }
            }

            else
            {
                list.Add(row.Cells[2].Text);
                row.BackColor = System.Drawing.Color.Yellow;
            }
        }
        Session["List"] = list;
    }

hi all,

i want to make the rows of my gridview editable on double click......i did this........but i hav som problems. Whenevr i double click the row......
it remains as it is.........i.e. only the color of the row changes....since i hav given a color to row on doubleclick........The text boxes in the row appear when there is another page load i.e. when any other row is double clicked........thus when a row is dblclicked it becomes editble after another row is clicked.......I want that the row shld become editable as soon as it is doubleclicked......Moreover i want that the first column of my gridview which actually shows the Primary key from the database shld remain as it is......the remaining cells of the row shld become editable........Guys please help

Here is my RowDataBound and RowCommand code....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.