| 单个属性 | Customer: <%# custID %> |
| 集合 Orders | <asp:ListBox id="List1" datasource='<%# myArray %>' runat="server"> |
| 表达式 Contact | <%# ( customer.FirstName + " " + customer.LastName ) %> |
| 方法的返回值 | Outstanding Balance: <%# GetBalance(custID) %> |
| Number of Records: <%# count.ToString() %> |
| <script language="VB" runat="server"> Sub Page_Load(sender As Object, e As EventArgs) Page.DataBind End Sub ReadOnly Property custID() As String Get Return "ALFKI" End Get End Property ReadOnly Property orderCount() As Integer Get Return 11 End Get End Property </script> <form action="DataBind1_vb.aspx" runat="server"> Customer: <b><%# custID %></b><br /> Open Orders: <b><%# orderCount %></b> </form> |
| <asp:DropDownList id="StateList" runat="server"> <asp:ListItem>CA</asp:ListItem> …… </asp:DropDownList> <asp:button ID="Button1" Text="Submit" OnClick="SubmitBtn_Click" runat="server"/> Selected State: <asp:label ID="Label1" text='<%# StateList.SelectedItem.Text %>' runat="server"/> |
| Sub Page_Load(sender As Object, e As EventArgs) If Not IsPostBack Then Dim values as ArrayList= new ArrayList() values.Add ( "IN") values.Add ( "KS") values.Add ( "MD") values.Add ( "MI") values.Add ( "OR") values.Add ( "TN") DropDown1.DataSource = values DropDown1.DataBind End If End Sub |
| Sub Page_Load(sender As Object, e As EventArgs) If Not IsPostBack Then Dim dt As DataTable Dim dr As DataRow Dim i As Integer '建立DataTable dt = New DataTable dt.Columns.Add(New DataColumn( "IntegerValue", GetType(Integer))) dt.Columns.Add(New DataColumn( "StringValue", GetType(String))) dt.Columns.Add(New DataColumn( "DateTimeValue", GetType(DateTime))) dt.Columns.Add(New DataColumn( "BooleanValue", GetType(Boolean))) '填充一些数据 For i = 1 To 9 dr = dt.NewRow() dr(0) = i dr(1) = "Item " + i.ToString() dr(2) = DateTime.Now.ToShortTimeString If (i Mod 2 <> 0) Then dr(3) = True Else dr(3) = False End If '把数据行添加到表 dt.Rows.Add(dr) Next GridView1.DataSource = New DataView(dt) GridView1.DataBind() End If End Sub |
| Sub Page_Load(sender As Object, e As EventArgs) If Not IsPostBack Then Dim h As Hashtable = new Hashtable() h.Add ( "key1", "value1") h.Add ( "key2", "value2") h.Add ( "key3", "value3") MyDataList.DataSource = h MyDataList.DataBind End If End Sub |
| Sub Page_Load(sender As Object, e As EventArgs) If Not IsPostBack Then Dim values as ArrayList= new ArrayList() values.Add (0) values.Add (1) values.Add (2) values.Add (3) values.Add (4) values.Add (5) values.Add (6) DataList1.DataSource = values DataList1.DataBind End If End Sub Function EvenOrOdd(number As Integer) As String If (number Mod 2 <> 0) Then Return "Odd" Else Return "Even" End If End Function <asp:DataList id="DataList1" ……> <ItemTemplate> Number Value: <%# Container.DataItem %> Even/Odd: <%# EvenOrOdd(Container.DataItem) %> </ItemTemplate> </asp:DataList> |
| <%# String.Format("{0:c}", (CType(Container.DataItem, DataRowView)("IntegerValue"))) %> |
| <%# DataBinder.Eval(Container.DataItem, "IntegerValue", "{0:c}") %> <%# Eval("IntegerValue", "{0:c}") %> |
| <%# CType(DataBinder.Eval(Container.DataItem, "BoolValue"), Boolean) %> |
文档说明:
相关文档
返回首页 | 关于本站 | | 友情链接 | 广告服务 | 意见建议 | 访客留言 | 本站论坛
Copyright© 2001-2006 ProgramBBS.com All Rights Reserved 版权所有©编程论坛
Email: 吉ICP备05009985号
感谢长春订餐网友情支持