1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > ASP.NET中 DropDownList+DetailsView(详细视图)的使用前台绑定

ASP.NET中 DropDownList+DetailsView(详细视图)的使用前台绑定

时间:2019-04-19 03:51:00

相关推荐

ASP.NET中 DropDownList+DetailsView(详细视图)的使用前台绑定

中 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" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/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 />该类的产品:<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>

/ylbtech/WebForm-Drop-XList.rar

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。