Hello
I am trying to add a tooltip to an asp.net datagrid row in the ItemDataBound event like this:
In the aspx page i added in the head:
and in the body:
When I run the code I get an error popup saying "Unterminated string constant". When i view the source it looks like this:
Can you identify the error?
I am trying to add a tooltip to an asp.net datagrid row in the ItemDataBound event like this:
Code:
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
Dim tooltip As New StringBuilder
tooltip.Append(IIf(dt.Rows(e.Item.ItemIndex).Item("Property_AgentCompany").ToString().Length > 0, "Agent Company: " & dt.Rows(e.Item.ItemIndex).Item("Property_AgentCompany").ToString() & "," & Environment.NewLine(), Nothing))
tooltip.Append(IIf(dt.Rows(e.Item.ItemIndex).Item("Property_Contact").ToString().Length > 0, "Contact: " & dt.Rows(e.Item.ItemIndex).Item("Property_Contact").ToString() & "," & Environment.NewLine(), Nothing))
tooltip.Append(IIf(dt.Rows(e.Item.ItemIndex).Item("Property_Tel").ToString().Length > 0, "Tel: " & dt.Rows(e.Item.ItemIndex).Item("Property_Tel").ToString() & "," & Environment.NewLine(), Nothing))
tooltip.Append(IIf(Not dt.Rows(e.Item.ItemIndex).Item("Age_Name").ToString().StartsWith("N/s"), "Age: " & dt.Rows(e.Item.ItemIndex).Item("Age_Name").ToString() & "," & Environment.NewLine(), Nothing))
tooltip.Append(IIf(Not dt.Rows(e.Item.ItemIndex).Item("Condition_Name").ToString().StartsWith("N/s"), "Condition: " & dt.Rows(e.Item.ItemIndex).Item("Condition_Name").ToString() & "," & Environment.NewLine(), Nothing))
tooltip.Append(IIf(Not dt.Rows(e.Item.ItemIndex).Item("PrevTenure_Name").ToString().StartsWith("N/s"), "Previous Tenure: " & dt.Rows(e.Item.ItemIndex).Item("PrevTenure_Name").ToString() & "," & Environment.NewLine(), Nothing))
tooltip.Append(IIf(Not dt.Rows(e.Item.ItemIndex).Item("Size_Name").ToString().StartsWith("N/s"), "Size: " & dt.Rows(e.Item.ItemIndex).Item("Size_Name").ToString() & "," & Environment.NewLine(), Nothing))
tooltip.Append(IIf(dt.Rows(e.Item.ItemIndex).Item("Property_Datecompleted").ToString().Length > 0, "Date completed: " & dt.Rows(e.Item.ItemIndex).Item("Property_Datecompleted").ToString(), Nothing))
Dim strTooltip As String = tooltip.ToString()
If dt.Rows(e.Item.ItemIndex).Item("Property_Datecompleted").ToString().Length = 0 Then
strTooltip = strTooltip.Remove(strTooltip.Length - 3, 3)
End If
e.Item.Attributes.Add("onmouseover", "return overlib('" & strTooltip & "');")
e.Item.Attributes.Add("onmouseout", "return nd();")
In the aspx page i added in the head:
Code:
<script type="text/javascript" src="Javascripts\OverLib\overlib.js"><!-- overLIB (c) Erik Bosrup --></script>
and in the body:
Code:
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
When I run the code I get an error popup saying "Unterminated string constant". When i view the source it looks like this:
Code:
<tr class="datagridRow" onmouseover="return overlib('Agent Company: Kostas Ltd.,
Contact: Victoria,
Tel: 07723360935,
Age: 1950 -1970,
Condition: Recently refurbished,
Previous Tenure: No LA history,
Size: Medium');" onmouseout="return nd();">
Can you identify the error?