编程实现>ASP.NET 3.5开发范例精讲精析>探讨FormView控件

FormView没有内置html表格样式,但功能与FormView一样。这意味着,功能我来,外观你来。

FormView控件的精微物质:各种显示模板(编辑,空数据,页头,页脚,纯显示,插入,分页),事件(插入,绑定,编辑等待),可视化绑定。

只是显示<%# Eval("数据库字段") %>,更新<%# Bind("数据库字段") %>

 

编程实现>ASP.NET 3.5开发范例精讲精析>探讨FormView控件>最浅显的例子

ExpandedBlockStart.gif FormView控件超基础例子
<% @ Page Language = " C# "  AutoEventWireup = " true "  CodeFile = " demo004.aspx.cs "  Inherits = " study_chapter12_demo004 "   %>

<! 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 > FormView控件超基础例子 </ title >
    
< style  type ="text/css" >
        .style1
        
{
            width
:  100% ;
        
}
    
</ style >
</ head >
< body >
    
    
< form  id ="form1"  runat ="server" >
    
< div >
    
< table  class ="style1" >
        
< tr >
            
< td >
                
< asp:DropDownList  ID ="DropDownList1"  runat ="server"  AutoPostBack ="True"  
                    DataSourceID
="SqlDataSource2"  DataTextField ="部门"  DataValueField ="部门" >
                
</ asp:DropDownList >
                
< asp:SqlDataSource  ID ="SqlDataSource2"  runat ="server"  
                    ConnectionString
="<%$ ConnectionStrings:chtNorthwind %>"  
                    DataSourceMode
="DataReader"  
                    SelectCommand
="SELECT DISTINCT [部门] FROM [章立民研究室] ORDER BY [部门]" >
                
</ asp:SqlDataSource >
            
</ td >
        
</ tr >
        
< tr >
            
< td >
                
< asp:GridView  ID ="GridView1"  runat ="server"  AllowPaging ="True"  
                    AutoGenerateColumns
="False"  DataKeyNames ="员工号码"  DataSourceID ="SqlDataSource1"  
                    EnableViewState
="False" >
                    
< Columns >
                        
< asp:CommandField  ShowSelectButton ="True"   />
                        
< asp:BoundField  DataField ="员工号码"  HeaderText ="员工号码"  InsertVisible ="False"  
                            ReadOnly
="True"  SortExpression ="员工号码"   />
                        
< asp:BoundField  DataField ="姓名"  HeaderText ="姓名"  SortExpression ="姓名"   />
                        
< asp:BoundField  DataField ="性别"  HeaderText ="性别"  SortExpression ="性别"   />
                        
< asp:BoundField  DataField ="部门"  HeaderText ="部门"  SortExpression ="部门"   />
                    
</ Columns >
                
</ asp:GridView >
                
< asp:SqlDataSource  ID ="SqlDataSource1"  runat ="server"  
                    ConnectionString
="<%$ ConnectionStrings:chtNorthwind %>"  
                    SelectCommand
="SELECT [员工号码], [姓名], [性别], [部门] FROM [章立民研究室] WHERE ([部门] = @部门)" >
                    
< SelectParameters >
                        
< asp:ControlParameter  ControlID ="DropDownList1"  Name ="部门"  
                            PropertyName
="SelectedValue"   />
                    
</ SelectParameters >
                
</ asp:SqlDataSource >
            
</ td >
        
</ tr >
        
< tr >
            
< td >
                
< asp:FormView  ID ="FormView1"  runat ="server"  DataKeyNames ="员工号码"  
                    DataSourceID
="SqlDataSource3" >
                    
< ItemTemplate >
                    
< table  border ="1" >
                    
< tr >< td > 员工号码: < asp:Label  ID ="Label1"  runat ="server"  Text ='<%#Eval("员工号码")  % > '>'> </ asp:Label ></ td ></ tr >
                    
</ table >
                    
</ ItemTemplate >
                
</ asp:FormView >
                
< asp:SqlDataSource  ID ="SqlDataSource3"  runat ="server"  
                    ConnectionString
="<%$ ConnectionStrings:chtNorthwind %>"  
                    SelectCommand
="SELECT * FROM [章立民研究室] WHERE ([员工号码] = @员工号码)" >
                    
< SelectParameters >
                        
< asp:ControlParameter  ControlID ="GridView1"  Name ="员工号码"  
                            PropertyName
="SelectedValue"   />
                    
</ SelectParameters >
                
</ asp:SqlDataSource >
            
</ td >
        
</ tr >
    
</ table >
    
</ div >
    
</ form >
</ body >
</ html >


 

转载于:https://www.cnblogs.com/samwu/archive/2010/11/04/1869428.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值