绑定到网格视图时如何最小化字符串的长度 [英] How to minimize lenth of string when binding to grid view

查看:66
本文介绍了绑定到网格视图时如何最小化字符串的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我试图在绑定到gridview时尽量减少刺痛的速度它正在工作,但是当我试图导出到excel表时它没有显示完整的文字,而不是它显示Sampletext .....像这样,



请帮助解决它。

Hi,

Iam trying to minimize the lenhth of sting when binding to gridview it is working, but when iam trying to export to excel sheet it is not showing complete text rather it show "Sampletext....." Like this,

Please help to sort it out.

推荐答案

您需要导出网格的源而不是网格本身。数据源将包含整个内容。
You need to export the source of the grid rather than the grid itself. The datasource will contain the entire content.


不截断字符串;使用CSS来隐藏溢出。



ASPX文件:

Don't truncate the string; use CSS to hide the overflow instead.

ASPX file:
<asp:TemplateField ItemStyle-CssClass="hide-overflow">
<ItemTemplate>
    <asp:Label runat="server"

        Text='<% Eval("DataItem.SKILLS") %>'

        ToolTip='<% Eval("DataItem.SKILLS") %>'

    />
</ItemTemplate>
</asp:TemplateField>





样式表:



Stylesheet:

.hide-overflow
{
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


下面是解决查询的代码,

string str =SampleText

if(str.Length> 5)

str = str.Substring(0,5)+...;







然后将是Sampl ......
Below is the code which solve your query,
string str="SampleText"
if (str.Length > 5)
str= str.Substring(0, 5) + "...";



Then out will be Sampl...


这篇关于绑定到网格视图时如何最小化字符串的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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