如何在工具提示中显示gridview行数据

编程入门 行业动态 更新时间:2024-10-25 14:30:28
本文介绍了如何在工具提示中显示gridview行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, i有一个表。它有Id,Name,Description等字段。我需要将数据绑定到gridview.for description column i需要在gridview中显示150个章程,当用户将鼠标悬停在该故障列上时,整个数据应显示在工具提示中。 可以任何人告诉我。这是我的代码。 感谢你,

< html xmlns = www.w3/1999/xhtml > < head runat = server > < title > < / title > < / head > < body > < 表格 id = form1 runat = server > < div > < asp:GridView ID = GridView1 runat = server onrowdatabound = GridView1_RowDataBound > < / asp:GridView > < ; / div > < / form > < / body > < / html >

aspx.cs: DataTable dt = new DataTable(); protecte d void Page_Load(object sender,EventArgs e) { if(!IsPostBack) { dt.Columns.Add(Id,typeof(int)); dt.Columns.Add(Name,typeof(string)); dt.Columns.Add(Description,typeof(string)); DataRow dr = dt。 NewRow(); dr [0] = 1001; dr [1] =sukumar; dr [2] = Hiiiiiiiiiii这是testeetteeeee Testttttttttttt malilll; dt.Rows.Add(dr); DataRow dr2 = dt.NewRow(); dr2 [0] = 1002; dr2 [1] =amala; dr2 [2] =Hiiiiiiiiiii这是样本的测试人员; dt.Rows.Add(dr2); DataRow dr1 = dt.NewRow(); dr1 [0] = 1003; dr1 [1] =akash; dr1 [2] =Sampleeeeeeee这是sampleeeeeeee Testttttttttttt malilll; dt。 Rows.Add(dr1); GridView1.DataSource = dt; GridView1.DataBind(); } } protected void GridView1_RowDataBound(object sender,GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { e.Row.ToolTip =(e.Row.DataItem as DataRowView)[ 描述] .ToString(); } }

解决方案

< asp:gridview id =grdUserdatarunat =serverwidth =90%ondatabound =grdUserdata _DataBoundxmlns:asp =#unknown> < columns> < asp:templatefield headertext =Edit> < itemtemplate> < asp:imagebutton id =Imgbtneditrunat =serverheight = 20pxtooltip =<%#Eval(id)=%& gt;=> ImageUrl =〜/ th.jpgOnClick =Imgbtnedit_Click 宽度=20px/> < itemstyle horizo​​ntalalign =中心verticalalign =中间>

ASPX

< asp:gridview id = GridView1 runat = server onrowdatabound = GridView1_RowDataBound autogeneratecolumns = False xmlns:asp = #unknown > < 列 > < asp:templatefield headertext = Id sortexpression = Id > < itemtemplate > < asp:label id = Label1 runat = server text = <% #Bind( Id)%> > ; < / asp:label > ; < / itemtemplate > < / asp:templatefield > < asp:templatefield headertext = 名称 sortexpression = 名称 &g t; < itemtemplate > < asp:label id = Label2 runat = server text = <% #Bind( 名称)%> > < / asp:label > < / itemtemplate > < / asp:templatefield > < asp:templatefield headertext = 描述 sortexpression = 描述 > < itemtemplate > < asp:label id = Label3 runat = server text = > < / asp:label > < / itemtemplate > < / asp:templatefield > & lt; asp:templatefield > < itemtemplate > < asp:hiddenfield id = HiddenField1 runat = server value = <% #Bind( 描述)%> / > < / itemtemplate > < ; / asp:templatefield > < / columns > < / asp:gridview >

C#代码 受保护 void GridView1_RowDataBound( object sender,GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView drv = e.Row.DataItem as DataRowView; Label test = e.Row.FindControl( Label3) as 标签; if (drv [ Description].ToString().Length > 150 ) { test.Text = drv [ 描述]。ToString()。子串( 0 , 150 )+ ...; } else { test.Text = drv [ 描述]。ToString(); } e.Row.ToolTip = drv [ 描述]的ToString(); } }

看到这个.. :) 在ASP.NET中使用JQuery在鼠标悬停的工具提示中显示GridView行详细信息 [ ^ ] 显示-gridview- row-details-in-tooltip-on-mouseover-using-jquery-in-Asp-Nettarget =_ blanktitle =New Window> ^ ] b $ b Display-GridView-Row-details-on-Cell-MouseOver-using-jQuery-ToolTip-Plugin-in-ASPNet.aspx [ ^ ]

Hi everyone, i have a table.It has a fields like Id,Name,Description.I need to bind the data to gridview.for description column i need to show 150 charters in gridview, when ever user mouse over on thatdescrption column entire data should be displayed in tool tip. can any one tell me please.here is my code. thanking you,

<html xmlns="www.w3/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" onrowdatabound="GridView1_RowDataBound"> </asp:GridView> </div> </form> </body> </html>

aspx.cs: DataTable dt = new DataTable(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Description", typeof(string)); DataRow dr = dt.NewRow(); dr[0] = 1001; dr[1] = "sukumar"; dr[2] = "Hiiiiiiiiiii This is the sampleeeeeeee Testttttttttttt malilll"; dt.Rows.Add(dr); DataRow dr2 = dt.NewRow(); dr2[0] = 1002; dr2[1] = "amala"; dr2[2] = "Hiiiiiiiiiii This is the sampleeeeeeee Testttttttttttt malilll"; dt.Rows.Add(dr2); DataRow dr1 = dt.NewRow(); dr1[0] = 1003; dr1[1] = "akash"; dr1[2] = "Sampleeeeeeee This is the sampleeeeeeee Testttttttttttt malilll"; dt.Rows.Add(dr1); GridView1.DataSource = dt; GridView1.DataBind(); } } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.ToolTip = (e.Row.DataItem as DataRowView)["Description"].ToString(); } }

解决方案

<asp:gridview id="grdUserdata" runat="server" width="90%" ondatabound="grdUserdata_DataBound" xmlns:asp="#unknown"> <columns> <asp:templatefield headertext="Edit"> <itemtemplate> <asp:imagebutton id="Imgbtnedit" runat="server" height="20px" tooltip="<%# Eval(" id")="" %&gt;"=""> ImageUrl="~/th.jpg" OnClick="Imgbtnedit_Click" Width="20px" /> <itemstyle horizontalalign="Center" verticalalign="Middle">

ASPX

<asp:gridview id="GridView1" runat="server" onrowdatabound="GridView1_RowDataBound" autogeneratecolumns="False" xmlns:asp="#unknown"> <columns> <asp:templatefield headertext="Id" sortexpression="Id"> <itemtemplate> <asp:label id="Label1" runat="server" text="<%#Bind("Id") %>"></asp:label> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="Name" sortexpression="Name"> <itemtemplate> <asp:label id="Label2" runat="server" text="<%#Bind("Name") %>"></asp:label> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="Description" sortexpression="Description"> <itemtemplate> <asp:label id="Label3" runat="server" text=""></asp:label> </itemtemplate> </asp:templatefield> <asp:templatefield> <itemtemplate> <asp:hiddenfield id="HiddenField1" runat="server" value="<%# Bind("Description") %>" /> </itemtemplate> </asp:templatefield> </columns> </asp:gridview>

C# code

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView drv = e.Row.DataItem as DataRowView; Label test = e.Row.FindControl("Label3") as Label; if (drv["Description"].ToString().Length > 150) { test.Text = drv["Description"].ToString().Substring(0, 150) + "..."; } else { test.Text = drv["Description"].ToString(); } e.Row.ToolTip = drv["Description"].ToString(); } }

see this.. :) Show GridView Row Details in Tooltip on Mouseover Using JQuery in ASP.NET[^] show-gridview-row-details-in-tooltip-on-mouseover-using-jquery-in-Asp-Net" target="_blank" title="New Window">^] Display-GridView-Row-details-on-Cell-MouseOver-using-jQuery-ToolTip-Plugin-in-ASPNet.aspx[^]

更多推荐

如何在工具提示中显示gridview行数据

本文发布于:2023-11-22 23:23:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:行数   提示   工具   如何在   gridview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!