欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP.NET中ListView(列表視圖)的使用前臺綁定附源碼

 更新時間:2013年03月05日 11:16:04   作者:  
ListView(列表視圖)想必大家都知道吧,接下來本文將介紹下ListView的使用前臺綁定,感興趣的你可不要錯過本文了哈
1.A,運行效果圖

 

1.B,源代碼
復(fù)制代碼 代碼如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DropLvw.aspx.cs" Inherits="DropLvw" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>無標(biāo)題頁</title>
</head>
<body>
<form id="form1" runat="server">
<div>
請選擇大分類:<asp:DropDownList ID="drop" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="CategoryName"
DataValueField="CategoryID">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]">
</asp:SqlDataSource>
<hr />
該分類下的產(chǎn)品:<br />
<asp:ListView ID="lvw" runat="server" DataKeyNames="ProductID"
DataSourceID="SqlDataSource2">
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' />
</td>
<td>
<asp:Label ID="ProductNameLabel" runat="server"
Text='<%# Eval("ProductName") %>' />
</td>
<td>
<asp:Label ID="CategoryIDLabel" runat="server"
Text='<%# Eval("CategoryID") %>' />
</td>
<td>
<asp:Label ID="UnitPriceLabel" runat="server" Text='<%# Eval("UnitPrice") %>' />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="">
<td>
<asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' />
</td>
<td>
<asp:Label ID="ProductNameLabel" runat="server"
Text='<%# Eval("ProductName") %>' />
</td>
<td>
<asp:Label ID="CategoryIDLabel" runat="server"
Text='<%# Eval("CategoryID") %>' />
</td>
<td>
<asp:Label ID="UnitPriceLabel" runat="server" Text='<%# Eval("UnitPrice") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
未返回數(shù)據(jù)。</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="插入" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="清除" />
</td>
<td>
&nbsp;</td>
<td>
<asp:TextBox ID="ProductNameTextBox" runat="server"
Text='<%# Bind("ProductName") %>' />
</td>
<td>
<asp:TextBox ID="CategoryIDTextBox" runat="server"
Text='<%# Bind("CategoryID") %>' />
</td>
<td>
<asp:TextBox ID="UnitPriceTextBox" runat="server"
Text='<%# Bind("UnitPrice") %>' />
</td>
</tr>
</InsertItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">
ProductID</th>
<th runat="server">
ProductName</th>
<th runat="server">
CategoryID</th>
<th runat="server">
UnitPrice</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="更新" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="取消" />
</td>
<td>
<asp:Label ID="ProductIDLabel1" runat="server"
Text='<%# Eval("ProductID") %>' />
</td>
<td>
<asp:TextBox ID="ProductNameTextBox" runat="server"
Text='<%# Bind("ProductName") %>' />
</td>
<td>
<asp:TextBox ID="CategoryIDTextBox" runat="server"
Text='<%# Bind("CategoryID") %>' />
</td>
<td>
<asp:TextBox ID="UnitPriceTextBox" runat="server"
Text='<%# Bind("UnitPrice") %>' />
</td>
</tr>
</EditItemTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' />
</td>
<td>
<asp:Label ID="ProductNameLabel" runat="server"
Text='<%# Eval("ProductName") %>' />
</td>
<td>
<asp:Label ID="CategoryIDLabel" runat="server"
Text='<%# Eval("CategoryID") %>' />
</td>
<td>
<asp:Label ID="UnitPriceLabel" runat="server" Text='<%# Eval("UnitPrice") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName], [CategoryID], [UnitPrice] FROM [Products] WHERE ([CategoryID] = @CategoryID)">
<SelectParameters>
<asp:ControlParameter ControlID="drop" DefaultValue="1" Name="CategoryID"
PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>

/web.config
復(fù)制代碼 代碼如下:

<connectionStrings>
<add name="NorthwindConnectionString" connectionString="Data
Source=.;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>

1.C,資源下載

相關(guān)文章

  • Asp.net中使用Sqlite數(shù)據(jù)庫的方法

    Asp.net中使用Sqlite數(shù)據(jù)庫的方法

    Sqlite是最近比較流行的數(shù)據(jù)庫了,擁有比Access高效快速,易操作易實施。完全不需要在客戶端進(jìn)行任何的配置,只需要在站點中引用入DLL文件即可使用了。
    2009-11-11
  • asp.net 2.0中利用Ajax2.0實現(xiàn)JSON傳送大量頁面數(shù)據(jù)

    asp.net 2.0中利用Ajax2.0實現(xiàn)JSON傳送大量頁面數(shù)據(jù)

    本人遇到一個程序頁面,要有很大量的數(shù)據(jù)進(jìn)行交互操作。
    2010-03-03
  • Bin 和 App_Code 文件夾介紹

    Bin 和 App_Code 文件夾介紹

    Bin 和 App_Code 文件夾介紹...
    2007-04-04
  • ASP.Net緩存總結(jié)及分析 分享

    ASP.Net緩存總結(jié)及分析 分享

    提高性能最好最快的辦法當(dāng)然是通過緩存來改善,對于任何一個web開發(fā)者都應(yīng)該善用緩存。Asp.net下的緩存機(jī)制十分強(qiáng)大,用好緩存機(jī)制可以讓我們極大的改善web應(yīng)用的性能,下面是一些總結(jié)的緩存的知識點,與大家分享交流:
    2013-06-06
  • 壓縮aspx頁面刪除多余空格的兩種方法

    壓縮aspx頁面刪除多余空格的兩種方法

    這篇文章主要介紹了壓縮aspx頁面移除多余空格的兩種方法,可以在發(fā)布頁面之前壓縮aspx,無須浪費web server的cpu,需要的朋友可以參考下
    2014-02-02
  • ASP.NET Core通用主機(jī)實現(xiàn)托管服務(wù)

    ASP.NET Core通用主機(jī)實現(xiàn)托管服務(wù)

    這篇文章介紹了ASP.NET Core通用主機(jī)實現(xiàn)托管服務(wù)的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-07-07
  • .NET 純分頁代碼實例

    .NET 純分頁代碼實例

    這篇文章介紹了.NET 純分頁代碼實例,有需要的朋友可以參考一下
    2013-09-09
  • asp.net core下給網(wǎng)站做安全設(shè)置的方法詳解

    asp.net core下給網(wǎng)站做安全設(shè)置的方法詳解

    這篇文章主要給大家介紹了關(guān)于asp.net core下給網(wǎng)站做安全設(shè)置的相關(guān)資料,文章通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2018-07-07
  • ASP.NET MVC3關(guān)于生成純靜態(tài)后如何不再走路由直接訪問靜態(tài)頁面

    ASP.NET MVC3關(guān)于生成純靜態(tài)后如何不再走路由直接訪問靜態(tài)頁面

    高訪問量類型的電子商務(wù)網(wǎng)站,需要將一些不是經(jīng)常變化的頁面生成靜態(tài)頁面,然后普通用戶就可以直接訪問這些靜態(tài)頁面而不用再訪問需要連接數(shù)據(jù)庫的動態(tài)頁面。那么ASP.NET MVC3中如何做到這一點呢
    2011-12-12
  • Entity?Framework?Core實現(xiàn)Like查詢詳解

    Entity?Framework?Core實現(xiàn)Like查詢詳解

    本文詳細(xì)講解了Entity?Framework?Core實現(xiàn)Like查詢的方法,文中通過示例代碼介紹的非常詳細(xì)。對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-02-02

最新評論