asp.net数据绑定之Eval和Bind 和等区别
Eval是asp.net1.1中常
用的绑定语法,它是“单向”的,即绑定时把数据源上相应的值赋到该控件上,Eval的任务就完成了
而Bind所谓的“双向”就是:在绑定时,把
数据源上相应的值赋到该控件上,并且,在提交时,自动提取用户在该控件上输入的值。
Code
<
EditItemTemplate
>
<
asp:Label
ID
="CityIDLabel1"
runat
="server"
Text
='<%#
Eval("CityID") %
>
'>
</
asp:Label
>
<
asp:TextBox
ID
="CityTextBox"
runat
="server"
Text
='<%#
Bind("City") %
>
'>
</
asp:TextBox
>
</
EditItemTemplate
>
又例:
Eval:绑定的是只读数据的显
示;Bind:可以绑定只读数据也可以绑定更新数据,Bind方法还把字段和控件的绑定属性联系起来,使得数据控件(比如GridView等)的
Update、Insert和Delete等方法可以使用这种联系来作出相应的处理。
Eval 和 Bind绑定的数据在<%#
%> 显示, 若对要显示的数据作修改或者操作也在<%# %> 中,例如:
1, 对显示的字符串作字符显示:
<%
# (
Eval
(
"
Address
"
)).ToString().SubString(
0
,
10
)
%>
显
示10位数的地址。
2, 对显示的信息作判断:
<%
# (
Eval
(
"
if_delete
"
)).ToString
==
"
yes
"
?
"
已删
除
"
:
"
未删除
"
%>
--------------------------------------------------------------------------------------------------------------------------------
<% %> An embedded code block is server code that executes during
the page's render phase. The code in the block can execute programming
statements and call functions in the current page class.
http://msdn2.microsoft.com/en-gb/library/ms178135(vs.80).aspx
<%=
%> most useful for displaying single pieces of information.
http://msdn2.microsof
相关文档:
【VS2008无法启动asp.net development server】的解决
今天在VS2008中浏览打开一个网页时,就弹出对话框“无法启动asp.net development server”,试了很多次都是这样,有时就提示“无法连接到asp.net development server”
在网上找到下面的解决方法:
========================================== ......
Asp.net常用的51个代码(非常实用)
1.//弹出对话框.点击转向指定页面
CODE:Response.Write("<script>window.alert('该会员没有提交申请,请重新提交!')</script>");
Response.Write("<script>window.location ='http://www.51aspx.com/bizpulic/upmeb.aspx'</script>");
2. ......
1、Session有什么重大BUG,微软提出了什么方法加以解决?
答:是iis中由于有进程回收机制,系统繁忙的话Session会丢失,可以用Sate server或SQL Server数据
库的方式存储Session不过这种方式比较慢,而且无法捕获Session的END事件。
2.产生一个int数组,长度为100,并向其中随机插入1-100,并且不能重复。
C# code
in ......
public static bool GetClientWeb()
{
bool result = false;
string clientType = string.Concat(HttpContext.Current.Request.UserAgent);
if (clientType.ToLower().Contains("mozilla") || clientType.ToLo ......