易截截图软件、单文件、免安装、纯绿色、仅160KB

Asp.net数据绑定

数据绑定以及Container.DataItem的具体分析
灵活的运用数据绑定操作
绑定到简单属性:<%#UserName%>
绑定到集合:<asp:ListBox id="ListBox1" datasource='<%# myArray%>' runat="server">
绑定到表达式:<%#(class1.property1.ToString() + "," + class1.property2.ToString())%>
绑定到方法返回值:<%# GetSafestring(str) %>
绑定到Hashtable:<%# ((DictionaryEntry)Container.DataItem).Key%>
绑定到ArrayList:<%#Container.DataItem %>
若数组里里放的是对象则可能要进行必要的转换后再绑定如:
<%#((对象类型)Container.DataItem).属性%>
绑定到DataView,DataTable,DataSet:
<%#((DataRowView)Container.DataItem)["字段名"]%>或
<%#((DataRowView)Container.DataItem).Rows[0]["字段名"]%>
要格式化则:
<%#string.Format("格式",((DataRowView)Container.DataItem)["字段名"])%>
<%#DataBinder.Eval(Container.DataItem,"字段名","格式")%>
绑定到DataReader:
<%#((IDataReader)Container.DataItem).字段名%>
当然为了方便一般使用最多的就是DataBinder类的Eval方法了.不过这样对于同时要绑定大量的数据效率要低一些
在绑定数据时经常会用到这个句程序:<%# DataBinder.Eval(Container.DataItem,"xxxx")%>或者<%# DataBinder.Eval(Container,"DataItem.xxxx")%>
今天又学到一种,而且微软也说这种方法的效率要比以上两种高。
<%# ((DataRowView)Container.DataItem)["xxxx"]%>
很有用的,这样可以在前台页面做好多事情了。
还要记住要这样用必须要在前台页面导入名称空间System.Data,否则会生成错误信息。
<%@ Import namespace="System.Data" %>
这种用法其实和<%# ((DictionaryEntry)Container.DataItem).Key%>是一个道理。
绑定到DataSet、DataTable时:
<%#((System.Data.DataRowView)Container.DataItem)["字段名"]%>
<%#((System.Data.DataRowView)Container.DataItem)[索引]%>
绑定到DataReader时:
<%#((System.Data.Common.DbDataRecord)Container.DataItem)[索引]%>
<%#((System.Data.Common.DbDataRecord)Container.DataItem)["字段名"]%>
关键是Container这个东西,它比较神秘。它的名称空间是System.ComponentModel。对于它我还需要进一步理解。
初学.NET,现在


相关文档:

asp.net 读取身份证源码

一般来说winform应用程序解决这个问题起来时很容易的,web应用程序就麻烦一点了。 这里我说说我的解决思路: 一、你必要有联机型居民身份证阅读器一个(带驱动光盘),这里我用的是精伦电子公司的iDR200,并有这个阅读器的开发接口说明。 二、新建一个winform控件项目ReadCardControl,添加一个主类ReadCard 1、 声明dll入口 ......

C# asp.net如何使用MD5加密,解密

using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;namespace md5
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(UserMd5("8"));
Console.WriteLine(GetMd5Str("8"));
}
/**//// &lt;summary&gt;
/// MD5 16位加密 ......

PHP与ASP.NET比较的浅析 南三方


 
PHP与ASP.NET比较的各个方面是什么呢?PHP与ASP.NET比较的必要性是什么呢?那么本文就给你一个答案。
PHP与ASP.NET比较的前言,不管你是不是已经选择了PHP,根据它在如下表格中在价格、速度、效率、安全性、平台支持性和开源与否上的表现,我们都能判断出它的强项是远胜于弱点的。唯一不足的是缺少面向对象的支 ......

Mix 10 上的asp.net mvc 2的相关Session

Beyond File | New Company: from Cheesy Sample to Social Platform Scott Hanselman in Lagoon L on Monday at 11:30 AM The web has changed and there's a new way of thinking about your applications. You can't just write some HTML and CSS anymore and expect to be the next Twitter. Hear h ......

ASP.NET中字符串进行MD5加密

最近在看《asp.net通用模块及典型系统开发实例导航》,其中用到了MD5加密,代码如下: /// <summary>
/// 字符串加密函数
/// </summary>
/// <param name="strInput">输入被加密的字符串</param>
/// <returns>加密后的字符串</return ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号