我有一个共同的网格视图柱过滤方法与的ColumnName和SEARCHTEXT明智滤波器网格视图记录.在这里,当我在可空INT DataColumn的操作也有像这个方法抛出错误:
类型'System.Int32'的表达式不能用于方法'Boolean Equals(System.Object)'的'System.Object'类型的参数
我的方法代码是:
public static IQueryable<T> FilterForColumn<T>(this IQueryable<T> queryable, string colName, string searchText)
{
if (colName != null && searchText != null)
{
var parameter = Expression.Parameter(typeof(T), "m");
var propertyExpression = Expression.Property(parameter, colName);
System.Linq.Expressions.ConstantExpression searchExpression = null;
System.Reflection.MethodInfo containsMethod = null;
// this must be of type Expression to accept different type of expressions
// i.e. BinaryExpression, MethodCallExpression, ...
System.Linq.Expressions.Expression body = null;
Expression ex1 = null;
Expression ex2 = null;
switch (colName)
{
case "JobID":
case "status_id": …Run Code Online (Sandbox Code Playgroud) 我正在使用网络应用程序.我在编译期间发现了错误.此代码中发生此错误:
public static void SendRegistrationEmail(string name, string ref_no, string email)
{
MailMessage msg = new MailMessage();
msg.IsBodyHtml = true;
SmtpClient client = GetSmtpClient();
string fromEmailAddress = ConfigurationManager.AppSettings["EASYTRACK_FromEmailAddress"];
string appPath = ConfigurationManager.AppSettings["EASYTRACK_PathToApplication"];
string subject = "EASYTRACK | User Registration";
string body = "<html><body>Thank you " + name + " !" +
" for registering your details with Easy Track.<br/><br/>" +
"Please click the following link to activate your account" +
"<br /><a href = '" + Request.Url.AbsoluteUri.Replace("Register.aspx", appPath + "My_Account.aspx?Ref=" + …Run Code Online (Sandbox Code Playgroud)