如何在工具提示中显示gridview行数据 [英] How to display gridview row data in tooltip

查看:121
本文介绍了如何在工具提示中显示gridview行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



i有一个表。它有Id,Name,Description等字段。我需要将数据绑定到gridview.for description column i需要在gridview中显示150个章程,当用户将鼠标悬停在该故障列上时,整个数据应显示在工具提示中。

可以任何人告诉我。这是我的代码。



感谢你,



 <   html     xmlns   =  http://www.w3.org/1999/xhtml >  
< head runat = server >
< title < span class =code-keyword>> < / title >
< / head < span class =code-keyword>>
< body >
< 表格 id = form1 runat = server >
< div >
< asp:GridView ID = GridView1 runat = server

onrowdatabound = < span class =code-keyword> 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();



}

}

解决方案

< blockquote>< 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  < span class =code-keyword> =  GridView1    runat   =  server    onrowdatabound   =  GridView1_RowDataBound    autogeneratecolumns   =  False    xmlns:asp   = #unknown >  
< >
< span class =code-keyword>< asp:templatefield headertext = Id sortexpression = Id >
< itemtemplate >
< asp:label id = Label1 < span class =code-attribute> 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 >
< <跨度class =code-leadattribute> asp:label id = Label3 runat = server text = > < / asp:label >
< / itemtemplate < span class =code-keyword>>
< / asp:templatefield >
& lt; asp:templatefield >
< itemtemplate >
< asp:hiddenfield id = HiddenField1 runat = server < span class =code-attribute> value = <% #Bind( 描述)%> / >
< / itemtemplate >
< ; / asp:templatefield >
< / columns >
< / asp:gridview >





C#代码

<前lang =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> ^ ]

< br $> 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="http://www.w3.org/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行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆