深入ASP.NET数据绑定(下)——多样的绑定方式
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-05-20
) 163: { 164: return ((IList) propertyValue)[(int) obj3]; 165: } 166: PropertyInfo info = propertyValue.GetType ().GetProperty("Item", BindingFlags.Public | BindingFlags.Instance, null, null, new Type[] { obj3.GetType() }, null); 167: if (info == null) 168: { 169: throw new ArgumentException(SR.GetString ("DataBinder_No_Indexed_Accessor", new object[] { propertyValue.GetType().FullName })); 170: } 171: return info.GetValue(propertyValue, new object[] { obj3 }); 172: } 173: 174: public static string GetIndexedPropertyValue(object container, string propName, string format) 175: { 176: object indexedPropertyValue = GetIndexedPropertyValue(container, propName); 177: if ((indexedPropertyValue == null) || (indexedPropertyValue == DBNull.Value)) 178: { 179: return string.Empty; 180: } 181: if (string.IsNullOrEmpty(format)) 182: { 183: return indexedPropertyValue.ToString(); 184: } 185: return string.Format(format, indexedPropertyValue); 186: } 187: 188: public static object GetPropertyValue(object container, string propName) 189: { 190: if (container == null) 191: { 192: throw new ArgumentNullException("container"); 193: } 194: if (string.IsNullOrEmpty(propName)) 195: { 196: throw new ArgumentNullException("propName"); 197: } 198: PropertyDescriptor descriptor = TypeDescriptor.GetProperties(container).Find(propName, true); 199: if (descriptor == null) 200: { 201: throw new HttpException(SR.GetString("DataBinder_Prop_Not_Found", new object[] { container.GetType ().FullName, propName })); 202: } 203: return descriptor.GetValue(container); 204: } 205: 206: public static string GetPropertyValue(object container, string propName, string format) 207: { 208: object propertyValue = GetPropertyValue(container, propName); 209: if ((propertyValue == null) || (propertyValue == DBNull.Value)) 210: { 211: return string.Empty; 212: } 213: if (string.IsNullOrEmpty (format)) 214: { 215: return propertyValue.ToString(); 216: } 217: return string.Format(format, propertyValue); 218: } 219: 220: internal static bool IsNull(object value) 221: { 222: if ((value != |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于深入ASP.NET数据绑定(下)——多样的绑定方式的所有评论