深入ASP.NET数据绑定(下)——多样的绑定方式
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-05-20
expressionParts.Length) && (propertyValue != null); i++) 33: { 34: string propName = expressionParts[i]; 35: if (propName.IndexOfAny(indexExprStartChars) < 0) 36: { 37: propertyValue = GetPropertyValue(propertyValue, propName); 38: } 39: else 40: { 41: propertyValue = GetIndexedPropertyValue(propertyValue, propName); 42: } 43: } 44: return propertyValue; 45: } 46: 47: public static string Eval(object container, string expression, string format) 48: { 49: object obj2 = Eval(container, expression); 50: if ((obj2 == null) || (obj2 == DBNull.Value)) 51: { 52: return string.Empty; 53: } 54: if (string.IsNullOrEmpty(format)) 55: { 56: return obj2.ToString(); 57: } 58: return string.Format(format, obj2); 59: } 60: 61: public static object GetDataItem(object container) 62: { 63: bool flag; 64: return GetDataItem(container, out flag); 65: } 66: 67: public static object GetDataItem(object container, out bool foundDataItem) 68: { 69: if (container == null) 70: { 71: foundDataItem = false; 72: return null; 73: } 74: IDataItemContainer container2 = container as IDataItemContainer; 75: if (container2 != null) 76: { 77: foundDataItem = true; 78: return container2.DataItem; 79: } 80: string name = "DataItem"; 81: PropertyInfo property = container.GetType().GetProperty (name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); 82: if (property == null) 83: { 84: foundDataItem = false; 85: return null; 86: } 87: foundDataItem = true; 88: return property.GetValue(container, null); 89: } 90: 91: public static object GetIndexedPropertyValue(object container, string expr) 92: { 93: if (container == null) 94: { 95: throw new ArgumentNullException("container"); 96: } 97: if (string.IsNullOrEmpty(expr)) 98: { 99: throw new ArgumentNullException("expr"); 100: } 101: object obj2 = null; 102: |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于深入ASP.NET数据绑定(下)——多样的绑定方式的所有评论