Eval( " ")和Bind( " ") 这两种一个单向绑定,一个双向绑定
bind是双向绑定,但需数据源可更改才能用
ASP.NET 2.0改善了模板中的数据绑定操作,把v1.x中的数据绑定语法DataBinder.Eval(Container.DataItem, fieldname)简化为Eval(fieldname)。Eval方法与DataBinder.Eval一样可以接受一个可选的格式化字符串参数。缩短的Eval语法与DataBinder.Eval的不同点在于,Eval会根据最近的容器对象(例如DataListItem)的DataItem属性来自动地解析字段,而DataBinder.Eval需要使用参数来指定容器。由于这个原因,Eval只能在数据绑定控件的模板中使用,而不能用于Page(页面)层。当然,ASP.NET 2.0页面中仍然支持DataBinder.Eval,你可以在不支持简化的Eval语法的环境中使用它。
下面的例子演示了如何使用新的简化的Eval数据绑定语法绑定到DataList数据项模板(ItemTemplate)中的Image、Label和HyperLink控件。
<asp:DataList ID= "DataList1 " RepeatColumns= "5 " Width= "600 " runat= "server " DataSourceID= "ObjectDataSource1 ">
<ItemTemplate>
<asp:HyperLink ID= "HyperLink1 " runat= "server " NavigateUrl= '<%# Eval( "PhotoID ", "Phot ......
影响ASP.Net应用性能的配置
1、删除不必要的HttpModule,每增加一个HttpModule,每个请求处理就多一点开销。
如:
<httpModules>
<!-- Remove unnecessary Http Modules for faster pipeline -->
<remove name="Session" /><!--不需要Session的可以删掉-->
<remove name="WindowsAuthentication" />
<remove name="PassportAuthentication" />
<remove name="AnonymousIdentification" />
<remove na ......
配置文件可用来存放一些多次用到的常量数据,如连接串:
<appSettings>
<add key="connStr1" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="/>
<add key="connStr2" value="App_Data\test.mdb"/>
</appSettings>
这个配置数据库连接串
使用示例:
public class DBConn
{
protected OleDbConnection _conn;
public DBConn(System.Web.UI.Page page)
{
string path = page.Server.MapPath(ConfigurationSettings.AppSettings["connStr2"]);
string connectString = ConfigurationSettings.AppSettings["connStr1"];
connectString += path;
_conn = new OleDbConnection(connectString);
_conn.Open();
}
........
<system.web> ......
执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.SqlClient.SqlException: 用户 'XXXASPNET' 登录失败。
今天将网站迁移过来后,就发现这个问题.经过摸索,发现原因是我们登录数据库的角色对数据库的权限不够.
解决办法:
1.打开数据库企业管理器,然后选择数据库---安全性---找到刚才报错的哪个'XXXASPNET' --右键"属性";
2.选择"用户映射"选项---在里面将我们要访问的数据库选中
3.先别点确定---再选择我们刚才选择的哪个数据库,在下面的"数据库角色成员身份"里要选择"db_owner"权限
至此,问题解决。 ......
下载页面:
<a href="download.ashx?url=<%=Server.UrlEncode("说明.txt")%>">下载</a>
------------------------------------------------------------------------------
download.ashx
<%@ WebHandler Language="C#" Class="download" %>
using System;
using System.Web;
public class download : IHttpHandler {
public void ProcessRequest (HttpContext context) {
string url = HttpContext.Current.Server.UrlDecode(context.Request.QueryString["url"]);
downloadfile(url);
}
public bool IsReusable {
get {
return false;
}
}
public void downloadfile(string s_fileName)
{
&n ......
1、DateTime 数字型
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒
currentTime=System.DateTime.Now;
1.2 取当前年
int 年=currentTime.Year;
1.3 取当前月
int 月=currentTime.Month;
1.4 取当前日
int 日=currentTime.Day;
1.5 取当前时
int 时=currentTime.Hour;
1.6 取当前分
int 分=currentTime.Minute;
1.7 取当前秒
int 秒=currentTime.Second;
1.8 取当前毫秒
int 毫秒=currentTime.Millisecond;
(变量可用中文)
1.9 取中文日期显示——年月日时分
string strY=currentTime.ToString( "f "); //不显示秒
1.10 取中文日期显示_年月
string strYM=currentTime.ToString( "y ");
......
1、DateTime 数字型
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒
currentTime=System.DateTime.Now;
1.2 取当前年
int 年=currentTime.Year;
1.3 取当前月
int 月=currentTime.Month;
1.4 取当前日
int 日=currentTime.Day;
1.5 取当前时
int 时=currentTime.Hour;
1.6 取当前分
int 分=currentTime.Minute;
1.7 取当前秒
int 秒=currentTime.Second;
1.8 取当前毫秒
int 毫秒=currentTime.Millisecond;
(变量可用中文)
1.9 取中文日期显示——年月日时分
string strY=currentTime.ToString( "f "); //不显示秒
1.10 取中文日期显示_年月
string strYM=currentTime.ToString( "y ");
......