zoukankan
html css js c++ java
控件数据绑定Xml做数据源
XmlDataSource Bind ServceControl
TextBox
RadioButtonList
Original Crust
Hand-Stretched Crust
Pan Crust
Oval Edge Crust
Square Crust
ListBox
Supreme
Capricciosa
Hawaiian
Mexican Fiesta
Italian Classic
Margherita
Meat Lover
Pepperoni
Vegetarian
CheckBoxList
Beef Bacon
Capsicum
Chicken
Fresh Tomato
Ham
Jalapno
Mushrooms
Olives
Onion
Pepperoni
Pineapple
RadioButtonList
No
Yes
<
form
id
="form1"
runat
="server"
>
<
h1
>
XmlDataSource Bind ServceControl
</
h1
>
<
table
width
="100%"
>
<
tr
>
<
td
>
TextBox
</
td
>
<
td
>
<
asp:TextBox
ID
="txtName"
Columns
="25"
runat
="server"
/>
</
td
>
</
tr
>
<
tr
>
<
td
valign
="top"
>
RadioButtonList
</
td
>
<
td
>
<
asp:RadioButtonList
ID
="rblCrust"
TextAlign
="right"
RepeatDirection
="horizontal"
RepeatColumns
="3"
RepeatLayout
="table"
DataTextField
="desc"
DataValueField
="value"
runat
="server"
/>
</
td
>
</
tr
>
<
tr
>
<
td
valign
="top"
>
ListBox
</
td
>
<
td
>
<
asp:ListBox
ID
="lstTopping"
Rows
="1"
DataTextField
="desc"
DataValueField
="value"
runat
="server"
/>
</
td
>
</
tr
>
<
tr
>
<
td
valign
="top"
>
CheckBoxList
</
td
>
<
td
>
<
asp:CheckBoxList
ID
="cblAdditionalTopping"
RepeatDirection
="horizontal"
TextAlign
="right"
RepeatColumns
="3"
RepeatLayout
="table"
DataTextField
="desc"
DataValueField
="value"
runat
="server"
/>
</
td
>
</
tr
>
<
tr
>
<
td
>
RadioButtonList
</
td
>
<
td
>
<
asp:RadioButtonList
ID
="rblDoubleCheese"
RepeatDirection
="horizontal"
TextAlign
="right"
RepeatLayout
="flow"
DataTextField
="desc"
DataValueField
="value"
runat
="server"
/>
</
td
>
</
tr
>
</
table
>
</
form
>
protected
void
Page_Load(
object
sender, EventArgs e)
{
String xmlFilePath
=
Server.MapPath(
"
XmlDataSource.xml
"
);
if
(
!
IsPostBack)
{
//
Create a new DataSet
DataSet dataSet
=
new
DataSet();
//
Read XML file and populate tables
dataSet.ReadXml(xmlFilePath);
//
Data bind RadioButtonList the verbose way
rblCrust.DataSource
=
dataSet;
rblCrust.DataMember
=
"
crust
"
;
rblCrust.DataBind();
//
Data bind ListBox the shortcut way
lstTopping.DataSource
=
dataSet.Tables[
"
topping
"
].DefaultView;
lstTopping.DataBind();
//
Data bind CheckBoxList in sorted order
DataView dataView
=
dataSet.Tables[
"
addtopping
"
].DefaultView;
dataView.Sort
=
"
desc Asc
"
;
cblAdditionalTopping.DataSource
=
dataView;
cblAdditionalTopping.DataBind();
//
Data bind RadioButtonList
rblDoubleCheese.DataSource
=
dataSet.Tables[
"
yesno
"
].DefaultView;
rblDoubleCheese.DataBind();
}
}
<?
xml version="1.0" encoding="utf-8"
?>
<
lookup
>
<!--
START OF: Topping
-->
<
topping
>
<
value
>
supreme
</
value
>
<
desc
>
Supreme
</
desc
>
</
topping
>
<
topping
>
<
value
>
capricciosa
</
value
>
<
desc
>
Capricciosa
</
desc
>
</
topping
>
<!--
END OF: Topping
-->
<!--
START OF: Additional Topping
-->
<
addtopping
>
<
value
>
onion
</
value
>
<
desc
>
Onion
</
desc
>
</
addtopping
>
<
addtopping
>
<
value
>
capsicum
</
value
>
<
desc
>
Capsicum
</
desc
>
</
addtopping
>
<!--
END OF: Additional Topping
-->
<!--
START OF: Crust
-->
<
crust
>
<
value
>
original
</
value
>
<
desc
>
Original Crust
</
desc
>
</
crust
>
<
crust
>
<
value
>
handstretched
</
value
>
<
desc
>
Hand-Stretched Crust
</
desc
>
</
crust
>
<!--
END OF: Crust
-->
<!--
START OF: Misc
-->
<
yesno
>
<
value
>
0
</
value
>
<
desc
>
No
</
desc
>
</
yesno
>
<
yesno
>
<
value
>
1
</
value
>
<
desc
>
Yes
</
desc
>
</
yesno
>
<!--
END OF: Misc
-->
</
lookup
>
查看全文
相关阅读:
WebService-.Net:添加web引用和添加服务引用有什么区别?
袁氏-人物-科学家:袁隆平(首届国家最高科学技术奖得主、杂交水稻之父)
术语-BLOB:BLOB
术语-PM:PM/项目管理 百科
计算机:SAP (服务访问点(Service Accessing point))
服务器-Web服务器-Tengine:Tengine 百科
笔记-Git:Git 笔记
DB-MDM:MDM/主数据管理 百科
DB-MD:MD/主数据
[Ext JS 4] 实战之 带week(星期)的日期选择控件
原文地址:https://www.cnblogs.com/RuiLei/p/897051.html
最新文章
python challenge第1关--NoteBook上的“乱码”
uva 10274 Fans and Gems(隐式图搜索+模拟)
Edit Box多行显示时如何使滚动条始终在下方
《数据通信与网络》笔记--SCTP
欧拉回路+图的连通性
TextKit学习(三)NSTextStorage,NSLayoutManager,NSTextContainer和UITextView
dns解析对SEO产生的影响
opencv 模板匹配与滑动窗口(单匹配) (多匹配)
【Cocos2d-X开发学习笔记】第21期:动画类(CCAnimate)的使用
渲染农场
热门文章
C入门程序整体框架图
linux编程vim设置
剖析tcp与udp及应用场景协议方案选择
oracle忘记sys及system密码
oracle实例侦听
cpu真实核数
exp
解压缩
oracle账户密码更新
.Net-WCF-图书:《WCF编程》
Copyright © 2011-2022 走看看