在DataGrid,DataList裡面怎麼控制列表裡得內容不換行,並且在800的分辨率下顯示12個漢字,24個英文字符,而在1024的分辨率下顯示15個漢字?
virtual protected void dgShow_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
DataGrid grid = (DataGrid)sender;
if( e.Item.ItemType == ListItemType.Item)
{
foreach(TableCell cell in e.Item.Cells )
cell.Attributes.Add("style","word-wrap:normal;break-word:keep-all");
}
}
還有,上面得代碼問什麼不能控制列表內容不換行啊
virtual protected void dgShow_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
DataGrid grid = (DataGrid)sender;
if( e.Item.ItemType == ListItemType.Item)
{
foreach(TableCell cell in e.Item.Cells )
cell.Attributes.Add("style","word-wrap:normal;break-word:keep-all");
}
}
還有,上面得代碼問什麼不能控制列表內容不換行啊
解决方案 »
- 未将对象引用设置到对象的实例
- .net1.1发送邮件问题
- |zyciis| 我生成word导出的时候 因为点了打开而不是保存时,以后他都是以网页打开的方式打开,但这时我要他为保存到本地,浏览器在哪里设置
- 求助: 常量
- vs.net2005中reportviewer的错误
- 池连接的问题
- 如何把图片存储进数据库并从数据库中读取出来?
- 怎么把上传到数据库中的图片正确显示在DataGrid控件中?目前显示的是System.Byte[] 。
- sos!!!很长时间都未解决,在drop1中绑定数据,再用drop1的值绑定为条件绑定drop2
- 数据源定位器问题
- 十万火急,请各位高手帮忙!!!
- IE Web Controls
下面给你一个根据文字的字节取长度的函数,你调用一下./// <summary>
/// 按字符串实际长度截取定长字符窜
/// </summary>
/// <param name="str">原字符串</param>
/// <param name="length">要截取的长度</param>
public static string GetString(string str, int length)
{
int i = 0, j = 0;
foreach(char chr in str)
{
if((int)chr > 127)
{
i += 2;
}
else
{
i ++;
}
if (i > length)
{
str = str.Substring(0, j) + "...";
break;
}
j ++;
}
return str;
}
關鍵是自動換行,就像Iput type = text 用px固定大小後,不會撐大表格,也不自動換行.
截取字符串,我覺得用BitConvert.GetBetyes()要好一些