数据绑定习题
- 格式:docx
- 大小:28.74 KB
- 文档页数:3
第9章数据绑定
一、选择题
1.在Web页面中中有一个名为dgStudent的GridView控件,为了禁止用户对该控件中的数据进行排序,应该添加()代码,以使GridView控件失去排序功能。
A.dgStudent.AllowSorting=true; B.dgStudent.AllowNavigation=true;
C.dgStudent.AllowNavigation=false; D.dgStudnet.AllowSorting=false;
2.在GridView上实现光棒效果,说法正确的是()。
A.在页面加载时,插入高亮显示的脚本B.在数据绑定时,插入高亮显示的脚本
C.在数据绑定后,插入高亮显示的脚本D.在数据行绑定时,插入高亮显示的脚本
3.以下控件,不是迭代控件的是()。
A.Repeater控件B.DataList控件C.GridView控件D.FormView控件
4.在ADONET中,已知有一个名为dsBook 的数据集,数据集中有一名为book 的数据表,下列能够正确将一个名为dgBook 的GridView 控件与数据集进行绑定的是()。
A.dsBook.SetDataBinding(dgBook,”book”);B.dsBook.SetDataBinding(dgBook);
C.dgBook.SetDataBinding(dsBook,”book”);D.dgBook.SetDataBinding(dsBook);
5.在中,下列可以作为GridView控件的数据源是()
(1)DataSet
(2)DataTable
(3)DataView
A.1和2 B.1和3 C.2和4 D.1. 2 3都可以
6.下列不属于ListControl类控件的是()。
A.GridView B.DropDownList C.ListBox D.CheckBoxList
7.要为DropDownList控件绑定主键值,需要设置其()属性。
A.DataSource B.DataValueField C.DataTextField D.Text
8.执行数据绑定表达式时,需要在Page_Load事件中编写下面哪段代码()。
A.Page.DataBind(); B.this.DataBind(); C.DataBind(); D.GridView.DataBind();
9.以下选项中不属于简单数据绑定的是()。
A.属性绑定B.表达式绑定C.集合绑定D.GridView数据绑定
10.DataList中显示数据时,需要在其()模板中进行设置。
A.HeaderTemplate B.FooterTemplate C.ItemTemplate D.SeparatorTemplate
二、填空题
1.GridView控件的基类是_________________。
2.GridView设置分页后,默认显示_________________条记录。
3.GridView控件提供了与分页相关的事件,_________________和_________________事件分别在执行分页操作之前和之后发生。
4.要为GridView控件绑定主键值,需要设置其_________________属性。
5.GridView控件的_________________属性代表正在编辑的行的索引,_________________属性代表当前选中行的索引。
6.在DataList控件实现分页显示数据时,需要借助_________________类来实现。
7.补充下面代码,每页只显示3条数据:
private void BindDataList(int currentpage)
{
pds.AllowPaging = true;
__________________________________
pds.CurrentPageIndex = currentpage;
string strSql = "SELECT * FROM tb_bookinfo";
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(strSql,conn);
DataSet ds = new DataSet();
sda.Fill(ds);
pds.DataSource = ds.Tables[0].DefaultView;
DataList1.DataSource = pds;
DataList1.DataBind();
conn.Close();
}
8.ListView控件的分页功能需要通过_________________控件来实现。
9.下面代码用来对GridView控件进行数据绑定,请将代码补充完整:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection("Data Source=(local);Database=db_LibraryMS;Uid=sa;Pwd=;");
SqlDataAdapter sqlda = new SqlDataAdapter("select * from tb_bookinfo", sqlcon);
DataSet ds = new DataSet();
sqlda.Fill(ds);
__________________________________
GridView1.DataBind();
}
10.要在GridView控件中删除数据,需要触发其_________________事件。