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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 软件之美,美在缺陷-Johnson

如何:在OpenText Workflow 6.5模型中保存和读取多行数据 轻松部署Captaris Workflow 6.5模型 浅比.NET和Java开发工具。 .NET资源转换工具 排除大型工作流应用的性能问题纪要。 淘宝网一家店里看到的留言和掌柜的搞笑回复。 Windows Network Load Balancing群集故障排除手记。 Captaris Workflow 6.0 EventService 执行效率低下的排除。 Captaris Workflow开发系列课程介绍。 在虚拟机里System进程占用CPU100%的问题解决 如何做好售前技术支持工作 一家公司网站上的招聘人才招聘栏目 VMWare 5.5 虚拟机错误。 Your've got mail A new post form Microsoft Live Writer. How to: Debug Captaris Workflow 6.0 Process efficiency? - 软件之美,美在缺陷-Johnson How to: Debug Captaris Workflow 6.0 Process efficiency? - 软件之美,美在缺陷-Johnson Captaris Workflow 6.0问题两则。 Recently learning about AJAX on ASP.NET
在GridView中使用ModalPopupExtender(转)
软件之美,美在缺陷-Jo · 2007-05-28 · via 博客园 - 软件之美,美在缺陷-Johnson

原文出处

当你不想在在GridView(或任何其它数据列表的控件中,如DataGrid/DataList等)编辑行时,有几种做法:

1.传递参数到另一个页面,在新的页面中进行修改;

2.获取GridView中选

择的行,在当前页面的另一些控件中显示控件并进行修改;

3.使用iFrame,直接在当前页嵌入另一个页面进行修改。

现在我们有了新的选择--使用ModalPopupExtender进行编辑,这个思路与第2点类似,只是增强了用户的视觉效果,使得用户在同一时间只能关注一个操作。

应用于GridView时,有一些需要注意的地方:

1.TargetControlID的设置,由于TargetControlID是必须设置的,而你希望在用户点击GridView中的某个Button或LinkButton或ImageButton时才使ModalPopup出现。可以这样,在页面上放置一个Button控件,通过设置Style="display: none;"隐藏这个控件。如:

         <asp:Button ID="btnHiddenPerson" runat="Server" Style="display: none" />

2.OKControlID的设置,你无需设置ModalPopupExtender的OKControlID属性。因为一旦设置了OKControlID,此控件的服务器OnClick事件便不会触发。相对应的,你应该设置CancelControlID属性。

3.GridView按钮事件的设置,因为事件是从GridView中的控件引发的,因此不可避免要到服务器端跑一次。你可以设置引发事件的Button事件不在OnRowCommand事件中处理,而是专门响应一个Button_Click事件来处理。如:

LinkButton btnApprove = sender as LinkButton;
GridViewRow row = (GridViewRow)btnApprove.NamingContainer;
Label lblRequestAmount = (Label)row.FindControl("lblAmount");
Label lblApproveAmount = (Label)row.FindControl("lblApprovedAmount");
this.lblOriginAmount.Text = lblApproveAmount.Text;
this.lblOriginRequestAmount.Text = lblRequestAmount.Text;
this.lblCurrentRowIndex.Text = row.RowIndex.ToString();
this.ModalPopupExtender.Show();

请注意其中第2句的写法,我特别喜欢。

示例代码请从原文处下载。