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

推荐订阅源

博客园 - 司徒正美
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
V2EX
MongoDB | Blog
MongoDB | Blog
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
D
Docker
S
Secure Thoughts
B
Blog
M
MIT News - Artificial intelligence
P
Privacy International News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Tenable Blog
Last Week in AI
Last Week in AI
A
About on SuperTechFans
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
月光博客
月光博客
L
Lohrmann on Cybersecurity
Security Latest
Security Latest
P
Proofpoint News Feed
有赞技术团队
有赞技术团队
P
Privacy & Cybersecurity Law Blog
Spread Privacy
Spread Privacy
AWS News Blog
AWS News Blog
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
小众软件
小众软件
宝玉的分享
宝玉的分享
量子位
Forbes - Security
Forbes - Security
T
Threatpost
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
H
Help Net Security
Help Net Security
Help Net Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
T
Troy Hunt's Blog
SecWiki News
SecWiki News
I
InfoQ
C
Cyber Attacks, Cyber Crime and Cyber Security
Stack Overflow Blog
Stack Overflow Blog

博客园 - 俩醒叁醉

ASP.NET MVC 4 WebAPI. Support Areas in HttpControllerSelector SQL2000安装问题(转) sql server 2008安装需要一直重启。但重启后又没有达到效果。 为数据库中所有的用户数据表生成分页存储过程 SQL 2005 字段备注获取 __doPostBack方法解析 如何在三个月掌握三年的经验(转载&&笔记) JQuery资源网站 Cookie跨域、虚拟目录 深入分析跨域cookie的问题 CnBlogsDotText使用实例 轻松搭建博客平台-开源ASP.NET 博客Subtext 的安装 表达式目录树(源MSDN) Web 2.0 编程思想:16条法则 Control Adapter 以下代码提供查询数据库中是否存在某个值 URL Routing MVC Controllers和Forms验证 CSharp——Lambda 表达式
jQuery Ajax的使用
俩醒叁醉 · 2009-04-03 · via 博客园 - 俩醒叁醉

场景:在Gridview列表中显示有从数据库提取出来的数据,现在要通过jQuery.Ui.Dialog弹出显示每条数据的详细信息,并在弹出窗口中修改编辑。

需要处理的问题:1、将Gridview中选择记录ID提交给jQuery.Ui.Dialog

                      2、保存处理

设计思路:

为数据绑定、数据更新设计一个aspx页面专门。通过调用jQuery ajax的load方法,载入数据绑定页面进而显示绑定的数据。

页面代码

<div id="loading" class="loading">
        服务器处理中,请稍后。
    
</div>
    
<div id="divBindShowData">
    
</div>
     
<data:EntityGridView ID="GridView1" DataSourceID="TbCorpCreditsInfoDataSource"  DataKeyNames="PrimaryKey" >
       
<Columns>
          
<asp:TemplateField HeaderText="查看/编辑">
               
<ItemTemplate>
                    
<asp:HyperLink ID="hlCreditScoreEdit" runat="server"  ImageUrl='Images/View.gif'   PrimaryKey='<%# DataBinder.Eval(Container.DataItem, "PrimaryKey") %>' />
               
</ItemTemplate>
           
</asp:TemplateField>
            
<asp:BoundField DataField="CorpName" HeaderText="企业名称" SortExpression="[CorpName]" />                    
            
<asp:BoundField DataField="CreditRank" HeaderText="信用等级" SortExpression="[creditRank]" />
        
</Columns>            
      
</data:EntityGridView>

js代码

// Dialog
            $('#divBindShowData').dialog({
                autoOpen: 
false,
                width: 
800,
                height: 
550,
                modal: 
true,
                title: 
"房地产开发企业信用评价编辑",
                buttons: {
                    
"保存"function() {
                        $.ajax({
                            type: 
"Post",
                            contentType: 
"application/html",
                            url: 
"CreditIntegralListUpdate.aspx?" + $("#divBindShowData input[type='text'][Id*='data']").serialize() + "&" + $("#divBindShowData input[Id*='primaryKey']").serialize(),
                            data: 
"",
                            dataType: 
'html',
                            success: 
function(result) { alert("更新成功!"); },
                            error: 
function(result, status) { //如果没有上面的捕获出错会执行这里的回调函数
                                if (status == 'error') {   alert(status);  }
                            }
                        });
                    },
                    
"取消"function() {
                        $(
this).dialog("close");
                    }
                }
            });
            
//
            $("a[Id*='hlCreditScoreEdit']").click(function() {
                $(
"#divBindShowData").load("CreditIntegralEdit.aspx?PrimaryKey=" + $(this).attr("PrimaryKey");
                $(
'#divBindShowData').dialog('open');
                
return false;
            });
            
//对与Ajax的监控,本身是全局性的
            $(document).ready(function() {
                $(
'#loading').ajaxStart(function() {
                    $(
this).show();
                    $(
this).floatdiv("middle");
                }).ajaxStop(
function() {
                    $(
this).hide();
                });
            });
        });

这里我通过.load 方法载入了CreditIntegralEdit.aspx页面的数据,而通过数列表CreditIntegralEdit.aspx中所有需要更新的字段,并将这序列化字符串通过ajax传递给CreditIntegralListUpdate.aspx页面。从而实现数据的绑定更新。