<%# DataBinder.Eval(Container.DataItem, "smalldir")%> 要取这个字段前2位.....怎么写?
解决方案 »
- 先装的.net后装的iis 导致访问aspx页面需要用户名和密码
- IsSynchronized 属性去那里了?
- DropDownList绑定的问题
- asp.net(C#)后台程序中如何获得打开自己的页面地址?
- 怎么在代码中动态生成一个Access数据库并建表关系等
- 请问如何接受Post方法传过来的数据
- 看看我这全选jquery有什么问题
- 帮个忙,来看看:在Lable 控件中动态的创建了5个文本框 现在怎样在C#中取出5个文本框的值赋给变量.
- about RegisterClientScriptBlock &javascript
- 如何才能点击网页上的超链接访问网上邻居的文件?
- 菜鸟急问:又是Tree View问题
- 如何在WEB应用程序中动态创建“数据库链接”,并进行多库间的数据联合查询??
后台写函数
public string getfirsttwo(string temp)
{
return temp.Substring(0,2);
}
这种方法比较简单.
<%# getfirsttwo(DataBinder.Eval(Container.DataItem, "smalldir").ToString())%>
后台写函数
public string getfirsttwo(string temp)
{
return temp.Substring(0,2);
}
<%#getnewstring(DataBinder.Eval(Container.DataItem, "name").ToString())%>
public string getnewstring(string wangzhe)
{
if(wangzhe.Length<2)
{
return wangzhe;
}
else
{
return wangzhe.Substring(0,2);
}
}
protected string CutString(string str,int length)
{
string newString="";
if(str!="")
{
if(str.Length>length)
{
newString=str.Substring(0,length)+"...";
}
else
{
newString=str;
}
}
return newString;
}
然后:
<%# CutString(DataBinder.Eval(Container.DataItem,"newtitle").ToString(),10) %>