①.时间
<%#Eval("BirthDay", "{0:yyyy-MM-dd}")%>
<%#Convert.ToDateTime(Eval("BirthDay")).ToShortDateString()%>
②.bool型
<%#(Eval("Gender")).ToString() =="True"?"男":"女"%>
<%# UserManager.Common.Function.GetStyleTrue(Eval("IsNotNull", "{0}"))%>
public static string GetStyleTrue(string str)
{
if ((str == "True") || (str == "1"))
return "√";
else
return "\x00d7";
}
③. 字符串过长,需要截取
<asp:Label ID="lblName" runat="server"
Text='<%#Eval("FieldName").ToString().Length>20Eval("FieldName").ToString().Substring(0,20)+"...":Eval("FieldName").ToString() %>' ToolTip='<%#Eval("FieldName") %>'></asp:Label>
④.显示值
<%#SuppliesManagement.BLL.SM_PrjMemberBll.GetProjectNameByProjectID(Convert.ToInt32(Eval("ProjectID")))%>
public static string GetProjectNameByProjectID(int projectID)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("SELECT [Name]");
strSql.Append(" FROM [Prj_Project]");
strSql.Append(" Where [ProjectId]=@ProjectID");
SqlParameter[] parameters = {
new SqlParameter("@ProjectID",SqlDbType.Int,4)
};
parameters[0].Value = projectID;
object result = SqlHelper.ExecuteScalar(SqlHelper.ConnectionString_BTC_Common, CommandType.Text, strSql.ToString(), parameters);
if (result == null || result.ToString() == "")
return "";
else
return result.ToString();
}
<%# UserManager.DAL.UserFieldDB.GetFieldType(Eval("FieldType", "{0}"))%>
public static string GetFieldType(string FieldType)
{
switch (FieldType)
{
case "TextType":
return "SingleText";
case "ListBoxType":
return "ListBox";
case "CheckBoxType":
return "CheckBox";
case "DateType":
return "Date";
case "MultipleTextType":
return "MultipleText";
case "RadioType":
return "RadioButton";
case "DropDownListType":
return "DropDownList";
case "RadomType":
return "随机数";
case "NumberType":
return "Number";
case "PasswordType":
return "Password";
case "CommentsType":
return "Comments";
case "ErLinkageType":
return "二级联动";
case "SanLinkageType":
return "三级联动";
}
return "";
}
⑤.按钮
<asp:LinkButton ID="lbtn_Up" runat="server" CommandName="UpMove" ForeColor="Blue" CommandArgument='<%# Eval("Id") %>' ToolTip="MoveUp">↑</asp:LinkButton>
<asp:ImageButton ID="imgbtnDel" runat="server" CommandName="Del" CommandArgument='<%# Eval("Id") %>' ImageUrl="~/images/del.gif" AlternateText="delete" OnClientClick="return confirm('This operation will delete and the field of relevant information.\r\n\r\n Are you sure to delete this field?')" Visible='<%# Eval("IsDelete").ToString()=="True"?true:false %>' />
⑥.图片
<img id="preview_<%# Eval("id") %>" src='<%# Eval("PhotoPath") %>' class="preview" onload="onPreviewLoad(this)" />