[英]How to show tooltip text in gridview row on mouseover?
我需要在gridview行的鼠標懸停上顯示工具提示。 我有復選框作為模板字段。 當禁用復選框時,我想顯示此工具提示。 下面是gridview rowdataboud
if (e.Row.RowType == DataControlRowType.DataRow)
{
string State = (e.Row.Cells[a].Text).ToString();
foreach (TableCell cell in e.Row.Cells)
{
if (State == "Y")
{
cell.BackColor = Color.Gray;
e.Row.Attributes.Add("onmouseover", "alert('This data is reserved');");
}
}
}
在這里,我不想顯示警報框,而是要顯示工具提示。
嘗試將標題屬性設置為:
e.Row.Attributes.Add("title", "This data is reserved");
當鼠標懸停在行上時,它將顯示默認樣式的工具提示,但是,您可能需要考慮jQuery UI工具提示插件
您只需要使用要使用該插件的元素對其進行初始化,例如,以下代碼將初始化並配置整個文檔的Tooltip插件:
<script src="Scripts/jquery-2.0.0.min.js"></script>
<script src="Scripts/jquery-ui-1.12.1.min.js"></script>
<link href="Content/themes/base/all.css" rel="stylesheet" />
<script type="text/javascript">
$(document).ready(function () {
$(document).tooltip();
});
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.