易截截图软件、单文件、免安装、纯绿色、仅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,现在


相关文档:

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 ......

Online active users counter in ASP.NET


Online active users counter in ASP.NET
With this tool which is written for ASP.NET, it is possible to count the number of online users, members and guest users in web sites.
Installation
The tool installation is very simple and only takes a few minutes.
Step one - Add Reference:
After downlo ......

asp.net准确截取文本长度(取得标题的字符数)

asp.net中自带的CutString只能截取字符数量的长度,但中英文字符数有差异,一个中文字等同于二个英文字符的宽度,这样对截取后的效果不理想.使用以下的方法就能解决.
//调用方法
string title=BLL.CutStr.CutString("标题",10);using System;
using System.Collections.Generic;
using System.Text;
namespace BLL
{
&n ......

使用WebClient自动填写并提交ASP.NET页面表单的源代码

 try
    {
        // 要提交表单的URI字符串。
        string uriString = "http://localhost:1165/WebTest/MyLogin.aspx";
        //// ......

asp.net 关闭网页代码

2种方法
一、linkbutton的单击事件里关闭页面,拼接代码就是了
补充,不可能,我自己试过,再补充一下
1.关闭时提示“是否关闭”
Response.Write("<script language:javascript>javascript:window.close();</script>");
2.直接关闭不提示
Response.Write("<script language:javascrip ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号