2012-11-08 14 views
5

जब उपयोगकर्ता ग्रिडव्यू में कॉलम के कॉलम शीर्षक पर होवर करता है उदाहरण के लिए: कॉलम हेडिंग वर्ष, जब मैं वर्ष में होवर करता हूं तो मुझे स्पष्टीकरण देखना चाहिए उस वर्ष का क्या अर्थ है "यह वह वर्ष है जब छात्र कॉलेज में शामिल हो गए थे"।ग्रिड व्यू कॉलम शीर्षक पर माउस पर टूलटिप कैसे जोड़ें

नीचे मेरी ascx कोड है:

<asp:GridView ID="grdView" runat="server" Width="900px" AutoGenerateColumns="False" 
       AllowPaging="true" AllowSorting="true" CellSpacing="0" CellPadding="5" PageSize="20" 
     OnRowDataBound="grdView_RowDataBound"> 
       <Columns> 
<asp:TemplateField HeaderText="ID Number" ItemStyle-Width="90px" > 
    <ItemTemplate> 
     <asp:Label ID="Label1" runat="server" Text='<%# Bind("ID")%'></asp:Label> 
    </ItemTemplate> 
</asp:TemplateField><asp:BoundField DataField="StudentName" HeaderText="StudentName"> </asp:BoundField> 

कृपया मुझे पता है कि कैसे मैं ग्रंथों या मेरे gridview के स्तंभ शीर्षकों पर टूलटिप्स अधिक मंडराना हो सकता हैं। धन्यवाद,

उत्तर

5

मैं किसी भी asp.net विकास कभी नहीं किया है, लेकिन वहाँ लगता है एक समाधान यहाँ उपलब्ध कराई जाने वाली:

<asp:GridView ID="grdView" runat="server" Width="900px" AutoGenerateColumns="False" 
      AllowPaging="true" AllowSorting="true" CellSpacing="0" CellPadding="5" PageSize="20" 
    OnRowDataBound="grdView_RowDataBound"> 
      <Columns> 
<asp:TemplateField HeaderText="ID Number" ItemStyle-Width="90px" > 
<HeaderTemplate> 
     <asp:Label ID="Header" ToolTip="HERE WE GO!!!!" runat="server" Text="Label"></asp:Label> 
     </HeaderTemplate> 
    <ItemTemplate> 
     <asp:Label ID="Label1" runat="server" Text='<%# Bind("ID")%'></asp:Label> 
    </ItemTemplate> 
</asp:TemplateField><asp:BoundField DataField="StudentName" HeaderText="StudentName"> </asp:BoundField> 

मैं देना होगा: how to add title for every header column in gridview in ASP.NET

अपने नमूना ऐसा दिखाई दे सकता कि एक कोशिश :)

5

अपने कोड में पीछे, GridView के लिए विधि rowDataBound बना सकते हैं और नीचे दिए गए कोड

जोड़ने

GridView में विशेषता OnRowDataBound सेट करना न भूलें।

http://rosshawkins.net/archive/2007/04/15/adding-tooltips-to-gridview-headers.html.aspx

+0

सेल, हेडर के बारे में क्या करता है? – SearchForKnowledge

+0

लिंक crs0794 पोस्ट हेडर पर टूलटिप्स जोड़ने का शानदार तरीका है। पढ़ने योग्य। जानकारी ग्राफिक के लिए – Doreen

6

Here is the CSS tooltip for Gridview in C# using Jquery

protected void grd_popup_details_RowDataBound(object sender, GridViewRowEventArgs e) 
    { 
     for (int i = 0; i < e.Row.Cells.Count; i++) 
     { 
      e.Row.Cells[i].ToolTip = e.Row.Cells[i].Text; 
     } 
    } 

Refference link

+0

प्लस 1 और कुछ भी नहीं! :) आप उसे कैसे करते हैं? – Fandango68

+0

केवल विशेष कॉलम के लिए टूल-टिप कैसे जोड़ें, केवल अपने उत्तरों में टिप्पणियों के लिए कहें –

0

इसका उपयोग करना संभव columnName के भी जब autogenerate = सच और GridView कॉलम गतिशील निर्धारित किया गया है।

इसके अलावा एचटीएमएलडीकोड() की आवश्यकता होती है जब पाठ में डबल कोट्स जैसे बच निकले वर्ण होते हैं।

Dictionary<string, int> _headerIndiciesForDetailsReportGridView = null; 

protected void detailsReportGridView_RowDataBound(object sender, GridViewRowEventArgs e) 
{ 
    if (_headerIndiciesForDetailsReportGridView == null) 
    { 
     int index = 0; 
     _headerIndiciesForDetailsReportGridView = ((Table)((GridView)sender).Controls[0]).Rows[0].Cells 
      .Cast<TableCell>() 
      .ToDictionary(c => c.Text, c => index++); 
    } 

    if (e.Row.RowType == DataControlRowType.DataRow) 
    {     
     TableCell cell = e.Row.Controls[_headerIndiciesForDetailsReportGridView["theColumnName"]] as TableCell; 

     // Set tooltip to the full original text. Decode to remove &quot, etc. 
     // 
     string orgText = cell.ToolTip = HttpUtility.HtmlDecode(cell.Text); 

     if (orgText.Length > 20) // If cell text should be shortened 
      cell.Text = HttpUtility.HtmlEncode(orgText.Substring(0, 20) + "..."); 
    } 
} 
संबंधित मुद्दे