1) 普通的绑定表达式
<%# DataBinder.Eval(Container.DataItem, "ContactName") %>
2) 文本+绑定表达式
<asp:Label id=lblDate runat="server" Text='<%# "[" + DataBinder.Eval(Container, "DataItem.NewsCreatedate") + "]" %>' ForeColor="Red"></asp:Label>
3) 同时带有显示格式的绑定表达式
<%# DataBinder.Eval(Container,"DataItem.USActiveDate","{0:yyyy-MM-dd}") %>
4) 结合绑定表达式和模态框
<A href='<%# ShowModalWin(Convert.ToString(DataBinder.Eval(Container.DataItem, "PictureImage")),Convert.ToString(DataBinder.Eval(Container.DataItem, "DetailID")),Convert.ToString(DataBinder.Eval(Container.DataItem, "PictureID")))%>'>
其中:后台代码文件中ShowModalWin()方法的定义如下:
protected string ShowModalWin(string PictureImage,string DetailID,string PictureID)
{
return " window.showModalDialog(\"Customers/ShowPictureInfo.aspx?pid="+PictureImage+"&did="+DetailID+"&id="+PictureID+"\",\"\",\"dialogHeight:320px;dialogWidth:480px;center:yes;help:no;status:no;scroll:no\");";
}
或者将参数提取出来单独定义成一变量:
const string WINDOWPARAMSTRING="dialogWidth:540px;dialogHeight:420px;help:0;status:0;resizeable:1;scroll:no";
Page.RegisterStartupScript("functionscript","<script language='javascript'>window.showModalDialog('EditUserService.aspx?URID="+iURID+"','','"+WINDOWPARAMSTRING+"')</script>");