小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

FormView控件

 行走在理想邊緣 2019-02-15

FormView控件是ASP.NET 2.0工具箱引入的,它的工作方式類似于DetailsView控件,也是顯示綁定數(shù)據(jù)源控件中的一個數(shù)據(jù)項,并可以添加、編輯和刪除數(shù)據(jù)。它比較獨特的 地方是在定制模板中顯示數(shù)據(jù),可以更多地控制數(shù)據(jù)的顯示和編輯方式。圖7-35顯示了在Visual Studio中編輯的FormView控件ItemTemplate。從中可以看出,我們能完全控制數(shù)據(jù)的顯示方式。FormView控件還包含 EditItemTemplate和InsertItemTemplate,它可以確定控件在進入編輯或插入模式下的顯示方式。

 
(點擊查看大圖)圖  7-35

圖7-35顯示了Visual Studio中的FormView控件。圖7-36顯示了FormView控件的ItemTemplate,表示在Visual Studio中設(shè)計的定制布局。

 
圖  7-36

在圖7-37中,該控件處于編輯模式,顯示了標(biāo)準的EditItemTemplate布局。

 
圖  7-37

程序清單7-58是在設(shè)計FormView控件的定制ItemTemplate時Visual Studio生成的代碼。

程序清單7-58  使用FormView控件顯示和編輯數(shù)據(jù)

<%@ Page Language="C#" %>
<html xmlns="http://www./1999/xhtml
" >
<head runat="server">
<title>Using the FormView control</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FormView ID="FormView1" Runat="server" DataSourceID="SqlDataSource1"
DataKeyNames="CustomerID" AllowPaging="True">
<EditItemTemplate>
CustomerID:
<asp:Label Text='<%# Eval("CustomerID") %>' Runat="server"
ID="CustomerIDLabel1">
</asp:Label><br />
CompanyName:
<asp:TextBox Text='<%# Bind("CompanyName") %>' Runat="server"
ID="CompanyNameTextBox"></asp:TextBox><br />
ContactName:
<asp:TextBox Text='<%# Bind("ContactName") %>' Runat="server"
ID="ContactNameTextBox"></asp:TextBox><br />
ContactTitle:
<asp:TextBox Text='<%# Bind("ContactTitle") %>' Runat="server"
ID="ContactTitleTextBox"></asp:TextBox><br />
Address:
<asp:TextBox Text='<%# Bind("Address") %>' Runat="server"
ID="AddressTextBox"></asp:TextBox><br />
City:
<asp:TextBox Text='<%# Bind("City") %>' Runat="server"
ID="CityTextBox"></asp:TextBox><br />
Region:
<asp:TextBox Text='<%# Bind("Region") %>' Runat="server"
ID="RegionTextBox"></asp:TextBox><br />
PostalCode:
<asp:TextBox Text='<%# Bind("PostalCode") %>' Runat="server"
ID="PostalCodeTextBox"></asp:TextBox><br />
Country:
<asp:TextBox Text='<%# Bind("Country") %>' Runat="server"
ID="CountryTextBox"></asp:TextBox><br />
Phone:
<asp:TextBox Text='<%# Bind("Phone") %>' Runat="server"
ID="PhoneTextBox"></asp:TextBox><br />
Fax:
<asp:TextBox Text='<%# Bind("Fax") %>' Runat="server"
ID="FaxTextBox"></asp:TextBox><br />
<br />
<asp:Button ID="Button2" Runat="server" Text="Button"
CommandName="update" />
<asp:Button ID="Button3" Runat="server" Text="Button"
CommandName="cancel" />
</EditItemTemplate>
<ItemTemplate>
<table width="100%">
<tr>
<td style="width: 439px">
<b>
<span style="font-size: 14pt">Customer Information</span>
</b>
</td>
<td style="width: 439px" align="right">
CustomerID:
<asp:Label ID="CustomerIDLabel" Runat="server"
Text='<%# Bind("CustomerID") %>'>
</asp:Label></td>
</tr>
<tr>
<td colspan="2">
CompanyName:
<asp:Label ID="CompanyNameLabel" Runat="server"
Text='<%# Bind("CompanyName") %>'>
</asp:Label><br />
ContactName:
<asp:Label ID="ContactNameLabel" Runat="server"
Text='<%# Bind("ContactName") %>'>
</asp:Label><br />
ContactTitle:
<asp:Label ID="ContactTitleLabel" Runat="server"
Text='<%# Bind("ContactTitle") %>'>
</asp:Label><br />
<br />
<table width="100%"><tr>
<td colspan="3">
<asp:Label ID="AddressLabel" Runat="server"
Text='<%# Bind("Address") %>'>
</asp:Label></td>
</tr>
<tr>
<td style="width: 100px">
<asp:Label ID="CityLabel" Runat="server"
Text='<%# Bind("City") %>'>
</asp:Label></td>
<td style="width: 100px">
<asp:Label ID="RegionLabel" Runat="server"
Text='<%# Bind("Region") %>'>
</asp:Label></td>
<td style="width: 100px">
<asp:Label ID="PostalCodeLabel"
Runat="server"
Text='<%# Bind("PostalCode") %>'>
</asp:Label>
</td>
</tr>
<tr>
<td style="width: 100px" valign="top">
<asp:Label ID="CountryLabel" Runat="server"
Text='<%# Bind("Country") %>'>
</asp:Label></td>
<td style="width: 100px"></td>
<td style="width: 100px">
Phone:
<asp:Label ID="PhoneLabel" Runat="server"
Text='<%# Bind("Phone") %>'>
</asp:Label><br />
Fax:
<asp:Label ID="FaxLabel" Runat="server"
Text='<%# Bind("Fax") %>'>
</asp:Label><br />
</td>
</tr></table>
<asp:Button ID="Button1" Runat="server"
Text="Button" CommandName="edit" />
</td>
</tr></table>
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" Runat="server"
SelectCommand="SELECT * FROM [Customers]"
ConnectionString="<%$ ConnectionStrings:AppConnectionString1 %>">
</asp:SqlDataSource>

</div>
</form>
</body>
</html>

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多