當前位置:編程學習大全網 - 網站源碼 - .Net怎麽在HTML頁面嵌入代碼以進行判斷?

.Net怎麽在HTML頁面嵌入代碼以進行判斷?

如果是GridView,那麽在其RowDataBound事件中寫代碼即可

例如:

protected void gvEmployeeBase_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Footer)

{

if (e.Row.RowIndex >= 0)

{

if(e.Row.Cells[7].Text=="0")

{

e.Row.Cells[7].Text="不存在";

}

if(e.Row.Cells[7].Text=="1")

{

e.Row.Cells[7].Text="存在";

}

//添加自定義屬性,當鼠標移過來時設置該行的背景色為"#EBEBED",並保存原背景色

e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#EBEBED'");

//添加自定義屬性,當鼠標移走時還原該行的背景色

e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");

}

}

}

  • 上一篇:pigx服務內部調用找不到其他微服務。
  • 下一篇:在按鍵精靈中判斷語句的寫法
  • copyright 2024編程學習大全網