This Way:
HTML:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.modalPopup
{
background-color: #FFFFFF;
border-width: 3px;
border-style: solid;
border-color: black;
padding-top: 10px;
padding-left: 10px;
width: 300px;
height: 50x;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<cc1:ToolkitScriptManager runat="server">
</cc1:ToolkitScriptManager>
<asp:DetailsView ID="dvDetails" runat="server" AutoGenerateRows="false" OnDataBound="dvDetails_DataBound">
<Fields>
<asp:TemplateField HeaderText="Name">
<ItemTemplate>
<asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Question">
<ItemTemplate>
<asp:Label ID="lblQuestion" runat="server" Text='<%# Eval("Question") %>'></asp:Label>
<asp:Panel ID="pnlDemo" CssClass="modalPopup" runat="server">
<asp:Label ID="lblLongAddress" Text='<%# Eval("Question") %>' runat="server"></asp:Label>
</asp:Panel>
<cc1:HoverMenuExtender ID="hmeDemo" runat="server" PopupControlID="pnlDemo" PopupPosition="Bottom"
TargetControlID="lblQuestion">
</cc1:HoverMenuExtender>
</ItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
</div>
</form>
</body>
</html>
C#:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt1 = new DataTable();
dt1.Columns.AddRange(new DataColumn[2] { new DataColumn("Name", typeof(string)),
new DataColumn("Question", typeof(string))
});
dt1.Rows.Add("Babu", "I want to display compnay details like company id, name, description, etc in DetailsView. The descrption is took long. So, I want to display first 100 characters from description initially and when user mouse over and want to display complete description in a popup. How to proceed to this kind of functionality ??");
this.dvDetails.DataSource = dt1;
this.dvDetails.DataBind();
}
}
protected void dvDetails_DataBound(object sender, EventArgs e)
{
Label question = dvDetails.FindControl("lblQuestion") as Label;
string newQuestion = question.Text.Substring(0, 100);
question.Text = newQuestion;
}
Image:
Here when i MouseOver the second cell of row 2 it shows this complete Question.