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

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

博客园 - 露雨城市.NET2.0和Sql Server 2005开发研究

关于asp.net将动态页直接生成静态页的随笔(乱码) 我的神龙卡KTV点播软件只有一个遗憾了 关于清除Sql Server Express版本的数据库日志文件 关于微软2008技术预览大会南京站和Vista 也许是转折-放弃了5,6K的月薪 关于vs2005中ajax控件暴露模板中控件,请高手进来聊聊. - 露雨城市.NET2.0和Sql Server 2005开发研究 这个基础题,你能做对吗? 好久没有来发文章了,今天来秀一下。 在.NET2.0中如何更简单的使用委托将方法加载到事件中去 Visual C#中父窗口和子窗口之间实现控件互操作 关于如何在子窗口中选择后,在父窗口赋值并让输入框设为只读。 - 露雨城市.NET2.0和Sql Server 2005开发研究 我的新资源网站开张了,韩国模版,韩国设计资源等。 今天好高兴,通过了微软的Sql Server 2005的70-31的考试。 赠送一张微软免费考试券 关于GridView中选择当前行的问题。 VS2005中的一个小BUG:关于Dropdownlist无法Datadinding的解决方法。 如何动态设置全局theme,及在web.config中读取pages节点的内容。 讲故事谈.NET委托:一个C#睡前故事 关于的MasterPage和Theme的问题。
关于在插入的模版中如何为已绑定了Text属性的TextBox设置默认值
露雨城市.NET2.0和Sql Server 2005开发研究 · 2006-06-05 · via 博客园 - 露雨城市.NET2.0和Sql Server 2005开发研究

很多时候,我们发现在插入模版中,想为TextBox设置一个默认值。
这时TextBox的Text属性已经绑定了数据表中的相关键值,不能去除,要不然就不能插入了。
那要怎么做呢?
其实很简单,就是为TextBox设置一个Value属性。
请看以下的代码示例:

  <asp:TemplateField HeaderText="家庭电话" SortExpression="Homephone">
            
<EditItemTemplate>
                
<asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("Homephone") %>'></asp:TextBox>
                
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="TextBox8"
                    ErrorMessage
="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
            
</EditItemTemplate>
            
<InsertItemTemplate>
                
<asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("Homephone") %>' Value="-"></asp:TextBox>
                
<asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="TextBox8"
                    ErrorMessage
="*" SetFocusOnError="True"></asp:RequiredFieldValidator>
            
</InsertItemTemplate>
            
<ItemTemplate>
                
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Homephone") %>'></asp:Label>
            
</ItemTemplate>

上面,我就是为TextBox8设置了一个默认的属性为"-",这样别人不想输入电话的时候,就不用输入了。