如题......看见在数据绑定的时候
<%# FormatState(DataBinder.Eval(Container.DataItem,"ID")) %>
前边的#号代表什么意思?还有
<add key="ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Data source="/>
<add key="DBPath" value="~/Databases/#db.mdb"/>数据库链接的数据库路径 ~/Databases/#db.mdb 前边的~又是代表什么意思?
还有能不能告诉小弟,这两个符号具体的意思,还有要用在什么地方?
谢过各位了...

解决方案 »

  1.   

    <%# %>  这是绑定数据
    ~代表目录,根目录
      

  2.   

    数据绑定表达式语法 当在页上调用 DataBind 方法时,数据绑定表达式创建服务器控件属性和数据源之间的绑定。可以将数据绑定表达式包含在服务器控件开始标记中属性/值对的值一侧,或页中的任何位置。 
    <tagprefix:tagname property="<%# data-binding expression %>"
       runat="server" />
    - or -
    literal text <%# data-binding expression %>
     
    参数
    property 
    为其声明数据绑定的控件属性。data-binding expression 
    符合备注部分中概述的要求的任意表达式。备注
    所有数据绑定表达式都必须包含在 <%# 和 %> 字符之间。ASP.NET 支持分层数据绑定模型,该模型创建服务器控件属性和数据源之间的绑定。几乎任何服务器控件属性都可以绑定到任何公共字段或属性,这些公共字段或属性位于包含页或服务器控件的直接命名容器上。数据绑定表达式使用 Eval 和 Bind 方法将数据绑定到控件,并将更改提交回数据库。Eval 方法是静态(只读)方法,该方法采用数据字段的值作为参数并将其作为字符串返回。Bind 方法支持读/写功能,可以检索数据绑定控件的值并将任何更改提交回数据库。可以使用 XPath 和 XPathSelect 方法以及 XPathBinder 类从 XmlDataSource 控件绑定到 XML 数据。有关更多信息,请参见 XmlDataSource Web 服务器控件。示例
    下面的代码示例演示如何在 ASP.NET 服务器控件中根据属性进行数据绑定。当用户从 DropDownList Web 服务器控件选择某个状态时,Label Web 服务器控件将根据列表中的选定项进行绑定并显示选中的状态。C#  复制代码 
    <html>
    <head>
        <script language="C#" runat="server">
            void SubmitBtn_Click(Object sender, EventArgs e) {
              // Rather than explictly pulling out the variable from the StateList control
              // and then manipulating a Label control, just call Page.DataBind.
              // This will evaluate any <%# %> expressions within the page.   
              Page.DataBind();
            }
        </script>
    </head>
    <body>    <h3><font face="Verdana">Binding to a property of another server control</font></h3>
        <form runat="server">
            <asp:DropDownList id="StateList" runat="server">
              <asp:ListItem>CA</asp:ListItem>
              <asp:ListItem>IN</asp:ListItem>
              <asp:ListItem>KS</asp:ListItem>
              <asp:ListItem>MD</asp:ListItem>
              <asp:ListItem>MI</asp:ListItem>
              <asp:ListItem>OR</asp:ListItem>
              <asp:ListItem>TN</asp:ListItem>
              <asp:ListItem>UT</asp:ListItem>
            </asp:DropDownList>       
            <asp:button Text="Submit" OnClick="SubmitBtn_Click" runat="server"/>        
            <p>     
            Selected State: <asp:label text='<%# StateList.SelectedItem.Text %>' runat="server"/>     
        </form>
    </body>
    </html> 
    Visual Basic  复制代码 
    <html>
    <head>
        <script language="VB" runat="server">
             Sub SubmitBtn_Click(sender As Object, e As EventArgs)
                ' Rather than explictly pulling out the variable from the StateList control
                ' and then manipulating a Label control, just call Page.DataBind.
                ' This will evaluate any <%# %> expressions within the page.   
                Page.DataBind()
             End Sub
        </script>
    </head>
    <body>    <h3><font face="Verdana"> Binding to a property of another server control</font></h3>
        <form runat="server">
            <asp:DropDownList id="StateList" runat="server">
              <asp:ListItem>CA</asp:ListItem>
              <asp:ListItem>IN</asp:ListItem>
              <asp:ListItem>KS</asp:ListItem>
              <asp:ListItem>MD</asp:ListItem>
              <asp:ListItem>MI</asp:ListItem>
              <asp:ListItem>OR</asp:ListItem>
              <asp:ListItem>TN</asp:ListItem>
              <asp:ListItem>UT</asp:ListItem>
            </asp:DropDownList>       
            <asp:button Text="Submit" OnClick="SubmitBtn_Click" runat="server"/>        
            <p>     
            Selected State: <asp:label text='<%# StateList.SelectedItem.Text %>' runat="server"/>     
        </form>
    </body>
    </html>
     请参见
    参考
    XPathBinder概念
    ASP.NET 网页介绍
    ASP.NET 网页语法概述其他资源
    Data Binding Using ASP.NET
    XmlDataSource Web 服务器控件
      

  3.   

    <%# %>  这是绑定数据
    ~代表目录,根目录这个是最简单的说法了,要是想知道更多,那就看Eddie005(♂) №.零零伍 (♂) ( ) 信誉:121    的细说了
      

  4.   

    都说的很清楚了,补充下,
    ~  一样用在服务器控件的根目录,不能用在HTML代码的根目录
      

  5.   

    这个本来就是个普通的小问题,像Eddie005(♂) №.零零伍 (♂) 说的,有点太详细了
    可以结贴了
      

  6.   

    @忽略转义符str1 = "\""; print  "
    str2 =@"\n"; print \n
      

  7.   

    不懂就要问吗
    不管问题大小Re:aiolia911()
      

  8.   

    Re:hy_lihuan() 不好意思啊
    你回复的时候我已经结帖了,没看见你回帖,所以分数没给你加上
    在此向你致歉! Sorry!