How to change the gridview row colors in onclick event in javascript?

前端 未结 3 2073
执笔经年
执笔经年 2021-01-25 13:18

I wrote the following GridView code in ASP.NET. I set the AlternatingRow style\'s BackColor to bisque. The remaining rows are set to white

3条回答
  •  渐次进展
    2021-01-25 13:56

    you can do like this...

     protected void MyGridView_RowCreated(object sender, GridViewRowEventArgs e)
     {
    
        string rowStyle = "this.style.backgroundColor
        = 'yellow'";
        string rowStyleClickedTwice =
        "this.style.backgroundColor = 'blue'";
        string rowID = String.Empty; 
    
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            rowID = "row"+e.Row.RowIndex; 
    
            e.Row.Attributes.Add("id",
            "row"+e.Row.RowIndex);
            e.Row.Attributes.Add("onclick",
            "ChangeRowColor(" +"'" + rowID + "'" + ")");
        }       
    }
    

    And this is the Java Script code:

     
     
    

    i hope it will helps you....

提交回复
热议问题