为了方便演示用xml文件做为数据源
xml文件:(UserInfo.xml)
<?xml version="1.0" standalone="yes"?>
<UserInfos>
<UserInfo>
<Email>some@you.net</Email>
<Name>me</Name>
<TEL>0123456</TEL>
</UserInfo>
<UserInfo>
<Email>youraddress@you.com</Email>
<Name>he</Name>
<TEL>7894563</TEL>
</UserInfo>
<UserInfo>
<Email>youraddress@you.com</Email>
<Name>222</Name>
<TEL>123342</TEL>
</UserInfo>
<UserInfo>
<Email>youraddress@you.com</Email>
<Name>haha</Name>
<TEL>3545445</TEL>
</UserInfo>
<UserInfo>
<Email>youraddress@you.com</Email>
<Name>sam</Name>
<TEL>879563</TEL>
</UserInfo>
</UserInfos>
页面代码:
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DGrid" runat="server" ShowFooter="True" GridLines="None" CellPadding="2" AutoGenerateColumns="False">
<HeaderStyle Font-Bold="True"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="名字">
<ItemTemplate>
<asp:TextBox id=Name runat="server" Width="109px" Text='<%# DataBinder.Eval(Container, "DataItem.Name") %>'>
</asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox id="NewName" runat="server" Width="109px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="电话">
<ItemTemplate>
<asp:TextBox id=TEL runat="server" Width="109px" Text='<%# DataBinder.Eval(Container, "DataItem.TEL") %>'>