gridview 在後台添加樣式

gridview 在後台添加樣式

檔鼠標移動到內容上背景顏色,字體顏色也改變,字體要添加下劃線 

 

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
   
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[0].Text = "合計:";

            e.Row.Cells[1].Text = string.Format("{0:n0}", double.Parse((myobject[1].ToString() == "") ? "0" : myobject[1].ToString()));
            //廠內交期訂單雙數
            e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Right;
           
            e.Row.Cells[2].Text = string.Format("{0:n0}", double.Parse((myobject[2].ToString() == "") ? "0" : myobject[2].ToString()));
            //預度數
            e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Right;

        }
      
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
               string factno = DropDownList3.SelectedValue.ToString().Trim();    
                for (int i = 1; i <= 1; i++)
                {
                    e.Row.Cells[i].Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.textDecoration='underline';this.style.backgroundColor='#7ecbc3';this.style.color='#FFFFFF';this.style.cursor='hand';");
                    e.Row.Cells[i].Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.color='black',this.style.textDecoration='none'");
                    string yyyymm = e.Row.Cells[0].Text.Trim();
                    //string factno = DropDownList3.SelectedValue.ToString().Trim();
                    string url = "OrderMasterDetail.aspx?yyyymm=" + yyyymm + "&fact_no=" + factno;
                    e.Row.Cells[i].Attributes.Add("onclick", "self.location='" + url + "'");
                }

        }
    }

你可能感兴趣的:(String,object,url)