| ylbtech-ASP.NET-Control-Bind:DropDownList+DetailsView(詳細視圖)的使用前臺綁定 |
?ASP.NET中 DropDownList+DetailsView(詳細視圖)的使用前臺綁定。
View Code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="DropDvw.aspx.cs" Inherits="DropDvw" %><!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>無標題頁
</title>
</head>
<body><form id="form1" runat="server"><div>請選擇大分類:<asp:DropDownList ID="dropYuanBo" 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)品:<asp:DetailsView ID="dvwYuanBo" runat="server" Height="50px" Width="125px" DataSourceID="SqlDataSource2"AllowPaging="True" AutoGenerateRows="False" DataKeyNames="ProductID"><Fields><asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"ReadOnly="True" SortExpression="ProductID" /><asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" /><asp:BoundField DataField="CategoryID" HeaderText="CategoryID" SortExpression="CategoryID" /><asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" /></Fields></asp:DetailsView><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"SelectCommand="SELECT [ProductID], [ProductName], [CategoryID], [UnitPrice] FROM [Products] WHERE ([CategoryID] = @CategoryID)"><SelectParameters><asp:ControlParameter ControlID="dropYuanBo" DefaultValue="1" Name="CategoryID" PropertyName="SelectedValue"Type="Int32" /></SelectParameters></asp:SqlDataSource></div></form>
</body>
</html> /web.config
<connectionStrings><add name="NorthwindConnectionString" connectionString="DataSource=.;Initial Catalog=Northwind;Integrated Security=True"providerName="System.Data.SqlClient"/></connectionStrings> http://files.cnblogs.com/ylbtech/WebForm-Drop-XList.rar
| | 作者:ylbtech 出處:http://ylbtech.cnblogs.com/ 本文版權(quán)歸作者和博客園共有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責(zé)任的權(quán)利。 |
轉(zhuǎn)載于:https://www.cnblogs.com/ylbtech/archive/2013/03/05/2943907.html
總結(jié)
以上是生活随笔為你收集整理的ASP.NET中 DropDownList+DetailsView(详细视图)的使用前台绑定的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。