绑定表达式

绑定表达式

localhost
Page.DataBind();
只有在执行这个方法时才会对整个页面的绑定表达式进行计算
对整个页面数据进行绑定,效率较低
->只对其中有些控件进行针对性的计算
指定控件进行数据绑定

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

App_code代码目录(创建类,类的目录)
Student.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.UI.WebControls;

public partial class _Default:System.Web.UI.Page
{
internal int x=10;
internal string[] arr1={"111","2222","333"};
internal Student stu1=new Student()
{
No="01",
Name="1111"
};
internal List<Student> List1=new List<Student>
{
new Student{No="02",Name="22222"},
new Student{No="03",Name="33333"}
};
protected void Page_Load(object sender,EventArgs e)
{
Page.DataBind();
}
}

Default.aspx


<DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" context="text/html:charset="utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text='<%# x %>'></asp:Label>
<asp:Buttun ID="Button1" runat="server" Text="Button"/>
<br/>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<asp:DropDownList ID="DropDownList1" DataSourse='<%#  %>'>

定义一个学生的对象,在创建对象的同时初始化
创建+初始化

数据源控件

treeview

DelectQuery
针对四种SQL语言

DataSet数据集

数据源控件
视图与数据库之间的桥梁
ConnectionString连接字符串
ConnectionString=“<%$ %>”

autoPostBack √

FilterExpression筛选表达式
SqlDataSourse1.FilterExpression=“city=‘上海’”;
S DropdownList1.SelectedValue

DropDownList &数据源控件

可实现动态查询功能

&gt 大于
&lt 小于

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值