惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
Jina AI
Jina AI
WordPress大学
WordPress大学
Recent Announcements
Recent Announcements
G
Google Developers Blog
I
InfoQ
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
C
Check Point Blog
J
Java Code Geeks
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Microsoft Security Blog
Microsoft Security Blog
MongoDB | Blog
MongoDB | Blog
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
量子位
A
About on SuperTechFans
D
DataBreaches.Net
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - Jason.Yi

远程机器上无法用Assembly.Load(path).CreateInstance(ClassName)? - Jason.Yi - 博客园 vs2005代码区出现问题 吉他自录之《回忆组曲》 吉他自录之《爱的罗曼史》 求助:Vs2005 asp.net development server未能开始侦听端口 为什么我的Cookie只能更新一个键值? 对Graphics.DrawImageUnscaledAndClipped的疑虑 哪些原因可能导致SQL操作操时呢? 二个算法题,大家有兴趣来看看 关于博客园的Calendar 费解的.net2.0中的ObjectDataSource控件 生成随机的颜色值 错误:已在多处定义 为什么本地sqlservr.exe进程占用内存如此之大? 这样的页面该如何实现? 简单的生成登录验证码的程序 遇到一个很奇怪的问题 连接SQL Server2005出错 能在web.config里做这样的配置吗?
FormView在什么情况下自动生成模板项?
Jason.Yi · 2006-04-07 · via 博客园 - Jason.Yi

刚才在鼓捣GridView与FormView,记得前一段时间在做时,点击gridview中的一项会在formview中显示详细的数据,而在 formview中只有编写了ItemTemplate等模板才会显示,我清楚的记得上次我并没有手工去编写itemTemplate模板,在查看、编辑、删除时的模板都是自动生成的,这次始终不成功,我又不愿意去手工写一些itemtemplate,如果有20个字段,我都手写就太累了。。。

偷懒之余,就用FormView的向导功能来做,不料,那些模板又自动生成了。怪。

Image81.png

也自动生成了如下模板:

<EditItemTemplate>
                CustomerID:
                
<asp:Label ID="CustomerIDLabel1" runat="server" Text='<%# Eval("CustomerID") %>'>
                
</asp:Label><br />
                CompanyName:
                
<asp:TextBox ID="CompanyNameTextBox" runat="server" Text='<%# Bind("CompanyName") %>'>
                
</asp:TextBox><br />
                ContactName:
                
<asp:TextBox ID="ContactNameTextBox" runat="server" Text='<%# Bind("ContactName") %>'>
                
</asp:TextBox><br />
                ContactTitle:
                
<asp:TextBox ID="ContactTitleTextBox" runat="server" Text='<%# Bind("ContactTitle") %>'>
                
</asp:TextBox><br />
                Address:
                
<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>'>
                
</asp:TextBox><br />
                City:
                
<asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>'>
                
</asp:TextBox><br />
                Region:
                
<asp:TextBox ID="RegionTextBox" runat="server" Text='<%# Bind("Region") %>'>
                
</asp:TextBox><br />
                PostalCode:
                
<asp:TextBox ID="PostalCodeTextBox" runat="server" Text='<%# Bind("PostalCode") %>'>
                
</asp:TextBox><br />
                Country:
                
<asp:TextBox ID="CountryTextBox" runat="server" Text='<%# Bind("Country") %>'>
                
</asp:TextBox><br />
                Phone:
                
<asp:TextBox ID="PhoneTextBox" runat="server" Text='<%# Bind("Phone") %>'>
                
</asp:TextBox><br />
                Fax:
                
<asp:TextBox ID="FaxTextBox" runat="server" Text='<%# Bind("Fax") %>'>
                
</asp:TextBox><br />
                
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                    Text
="更新">
                
</asp:LinkButton>
                
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                    Text
="取消">
                
</asp:LinkButton>
            
</EditItemTemplate>


下面是该FormView的DataSource:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            InsertCommand
="insert into customers (CustomerID,CompanyName,ContactName,ContactTitle,Address,City) values (@customerid,@companyname,@contactName,@contactTitle,@address,@city)"
            SelectCommand
="select * from customers where customerid=@customerid" UpdateCommand="update customers set companyname=@companyname,contactName=@contactName,contactTitle=@contactTitle where customerid=@customerid">
            
<UpdateParameters>
                
<asp:Parameter Name="companyname" />
                
<asp:Parameter Name="contactName" />
                
<asp:Parameter Name="contactTitle" />
                
<asp:Parameter Name="customerid" />
            
</UpdateParameters>
            
<SelectParameters>
                
<asp:Parameter Direction="input" Name="customerid" Type="string" />
            
</SelectParameters>
            
<InsertParameters>
                
<asp:Parameter Name="customerid" />
                
<asp:Parameter Name="companyname" />
                
<asp:Parameter Name="contactName" />
                
<asp:Parameter Name="contactTitle" />
                
<asp:Parameter Name="address" />
                
<asp:Parameter Name="city" />
            
</InsertParameters>
        
</asp:SqlDataSource>


直到现在还是晕晕的,不知道怎么样才能使之自动生成模板,难道只有在向导的情况下才会生成?