使用DataGrid时,如需将某列限定显示字数,当鼠标移动到该列上会显示出全部的内容,该怎么做? 写一个格式化字符串的函数 string cutStr(string str,int len),在绑定datagrid的时候用,具体算法很简单,你应该可以写把.另外把全部的的字符串内容写道title中.这样就可以将鼠标指向这一行,会显示每条信息标题的完整内容 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 需要处理的字段按以下方法处理前台需要将实现你所要功能的列设置为模板列,例如:<asp:TemplateColumn><ItemTemplate><asp:Label runat="server" Text='<%# ShorterText(DataBinder.Eval(Container, "DataItem.YourText")) %>' ToolTip='<%# DataBinder.Eval(Container, "DataItem.YourText") %>'></asp:Label></ItemTemplate></asp:TemplateColumn>后台增加一个protected的函数ShorterTextprotected string ShorterText(object obj){string returnValue=object.toString().Trim();if(returnValue.Length>15)return returnValue.SubString(0,12)+"...";elsereturn returnValue;} 上面的方法可行,也有另外一种方法,在后台循环给datagrid的每一项加入属性.前台的datagrid照常绑定(即不用模板列的方式).foreach(DataGridItem item in this.DataGrid1.Items) { item.Cells[1].Attributes["onmouseover"]="showlable('"+item.Cells[1].Text+"')"; item.Cells[1].Attributes["onmouseout"]="hidelable()"; //item.Cells[1].Text="1111"; }然后,在客户端写showlable函数来显示该值,显示的方法可以用div层的方式.要注意层的定位问题,一般要通过获取当前鼠标坐标的方法来定位.客户端代码部分参考:div1.style.position="absolute";div1.style.background="red";div1.style.left=event.clientX; //获取鼠标x坐标div1.style.top=event.clientY-10;div1.style.visibility="visible";......... 如何在SQL语句里面拼接 请教这个正则是如何理解的啊 System.IO.DirectoryNotFoundException: 未找到路径“h:\”的一部分。 启动MSDN Library后,目录栏能正常显示,但右边总是提示无法显示网页内容。请问如何解决? 新建的.net技术讨论区QQ群,欢迎.net高手和爱好者加入!! DataSet更新问题 请教:如何在ASP.NET的页面中,列出服务器所有的硬盘序列号 wpf程序不能在win2008上运行 ASP.NET 的安装问题? datagrid 中如何排序??? 一个页面间传递参数的问题 asp.net里有相当于rs("name")的函数吗?
前台
需要将实现你所要功能的列设置为模板列,例如:
<asp:TemplateColumn>
<ItemTemplate>
<asp:Label runat="server" Text='<%# ShorterText(DataBinder.Eval(Container, "DataItem.YourText")) %>' ToolTip='<%# DataBinder.Eval(Container, "DataItem.YourText") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
后台增加一个protected的函数ShorterText
protected string ShorterText(object obj)
{
string returnValue=object.toString().Trim();
if(returnValue.Length>15)
return returnValue.SubString(0,12)+"...";
else
return returnValue;
}
foreach(DataGridItem item in this.DataGrid1.Items)
{
item.Cells[1].Attributes["onmouseover"]="showlable('"+item.Cells[1].Text+"')";
item.Cells[1].Attributes["onmouseout"]="hidelable()";
//item.Cells[1].Text="1111";
}然后,在客户端写showlable函数来显示该值,显示的方法可以用div层的方式.要注意层的定位问题,一般要通过获取当前鼠标坐标的方法来定位.客户端代码部分参考:
div1.style.position="absolute";
div1.style.background="red";
div1.style.left=event.clientX; //获取鼠标x坐标
div1.style.top=event.clientY-10;
div1.style.visibility="visible";
.........