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
>
查看全文
相关阅读:
MySQL锁之三:MySQL的共享锁与排它锁编码演示
服务链路追踪(Spring Cloud Sleuth)
服务网关zuul之四:zuul网关配置
hdu 1505 City Game (hdu1506加强版)
PHP设计模式——訪问者模式
极客互联网电视不是噱头,用户体验成创维G7200核心竞争力
深入理解JavaScript系列(23):JavaScript与DOM(上)——也适用于新手
使用php分页类实现简单分类
管理之路(四)
poj 2485 Highways (最小生成树)
原文地址:https://www.cnblogs.com/RuiLei/p/897051.html
最新文章
Springboot配置使用ssl,使用https
flume使用之httpSource
Hive的UDF是什么?
Hive数据导入导出的几种方式
如何做一个对账系统
hive中的表
Hive入门介绍
运行java飞行记录器JFR(java flight recorder)
Java性能调优:利用JMC分析性能
JVM异常之:直接内存溢出
热门文章
JVM异常之:堆溢出OutofMemoryError
JVM异常之:方法区溢出OutOfMemoryError: PermGen space
JVM异常之:栈溢出StackOverflowError
Heap堆分析(堆转储、堆分析)
详解MySQL主从复制实战
SpringCloud之个性化日志追踪
分布式系统的一致性探讨
【转】微服务架构下的数据一致性保证(三):补偿模式
【转】微服务架构下的数据一致性保证(二):可靠事件模式
【转】微服务架构下的数据一致性保证(一)
Copyright © 2011-2022 走看看