Asp.net 如何将实体框架5.0与jQuery Datatable和fancybox一起使用

Asp.net 如何将实体框架5.0与jQuery Datatable和fancybox一起使用,asp.net,entity-framework-5,updatepanel,fancybox-2,jquery-datatables,Asp.net,Entity Framework 5,Updatepanel,Fancybox 2,Jquery Datatables,我不熟悉EF和jQuery数据表。我有两个实体叫做国家和州。 我像这样绑着我的国家电网 public void BindGrid() { using (var db = new DefaultCS()) { var query = from c in db.CountryMasters orderby c.CountryId ascending

我不熟悉EF和jQuery数据表。我有两个实体叫做国家和州。 我像这样绑着我的国家电网

public void BindGrid()
    {
        using (var db = new DefaultCS())
        {
            var query = from c in db.CountryMasters
                        orderby c.CountryId ascending
                        select c;
            GridView1.DataSource = query.ToList();
            GridView1.DataBind();
        }
    }


函数fnClickRedraw(){
可变的;
$(文档).ready(函数(){
TableTools.DEFAULTS.aButtons=[“复制”、“csv”、“xls”、“pdf”、“打印”]
oTable=$('#')。数据表({
“阿伦提努”:[[10,25,50,100,-1],[10,25,50,100,“全部”],
“iDisplayLength”:10,
“aaSorting”:[[0,“asc”]],
“bJQueryUI”:没错,
“bRetrieve”:true,“sPaginationType”:“完整数字”,
“sDom”:“lt”,
//----打印\导出\复印----
“sDom”:“Tt”和“oTableTools”:{
“sSwfPath”:“./Content/DataTables-1.9.4/extras/tablettools/media/swf/copy\u csv\u xls\u pdf.swf”
},
“bAutoWidth”:对
});
oTable.$('tr').hover(函数(){$(this.addClass(“hover”);},函数(){$(this.removeClass(“hover”);});
可旋转。$('tr').css(“光标”、“指针”);
可旋转。$('td')。单击(函数(){
var aPos=可旋转的.fGetPosition(此);
var aData=oTable.fngedata(aPos[0]);
$.fancybox({
“标题秀”:假,
“宽度”:600,
‘高度’:460,
'href':'CountryNew.aspx?代码='+aData[0]+',
'type':'iframe',
“transitionIn”:“弹性”,
“transitionOut”:“弹性”,
“closeClick”:false,
“助手”:{
覆盖:{
closeClick:false,
showEarly:错误
}
},
“产能过剩”:0.7,
“beforeClose”:函数(){document.getElementById(“”)。单击();}
});
});
});
/*获取当前选定的行*/
功能fnGetSelected(oTableLocal){
返回oTableLocal.$('tr.hover');
}
}
函数页面加载(发送方,参数){
$(“#btnCreate”).fancybox({
“标题秀”:假,
“宽度”:600,
‘高度’:460,
'type':'iframe',
“transitionIn”:“弹性”,
“transitionOut”:“弹性”,
“closeClick”:false,
“助手”:{
覆盖:{
closeClick:false,
showEarly:错误
}
},
“产能过剩”:0.7,
“enableEscapeButton”:false,
“showCloseButton”:false,
“beforeClose”:函数(){document.getElementById(“”)。单击();}
});
}
当我点击fancybox中的网格行编辑国家表单popedup,编辑后,我调用了一个隐藏按钮,使用更新面板重新绑定网格。创建新国家/地区的Sam程序。 我的问题:如何在不使用更新面板的情况下插入新国家/地区? 提前谢谢

<script type="text/javascript">
    function fnClickRedraw() {
        var oTable;
        $(document).ready(function () {
            TableTools.DEFAULTS.aButtons = ["copy", "csv", "xls", "pdf", "print"]
            oTable = $('#<%=GridView1.ClientID %>').dataTable({
                "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
                "iDisplayLength": 10,
                "aaSorting": [[0, "asc"]],
                "bJQueryUI": true,
                "bRetrieve": true, "sPaginationType": "full_numbers",
                "sDom": '<"top"i><"title">lt<"bottom"pf>',
                // ----  Print_Export_Copy  ----                
                "sDom": 'T<"clear"><"H"lfr>t<"F"ip>', "oTableTools": {
                    "sSwfPath": "../Content/DataTables-1.9.4/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
                },


                "bAutoWidth": true
            });

            oTable.$('tr').hover(function () { $(this).addClass("hover"); }, function () { $(this).removeClass("hover"); });
            oTable.$('tr').css("cursor", "pointer");
            oTable.$('td').click(function () {
                var aPos = oTable.fnGetPosition(this);
                var aData = oTable.fnGetData(aPos[0]);
                $.fancybox({
                    'titleShow': false,
                    'width': 600,
                    'height': 460,
                    'href': 'CountryNew.aspx?Code=' + aData[0] + '',
                    'type': 'iframe',
                    'transitionIn': 'elastic',
                    'transitionOut': 'elastic',
                    'closeClick': false,
                    'helpers': {
                        overlay: {
                            closeClick: false,
                            showEarly: false
                        }
                    },
                    'overlayOpacity': 0.7,
                    'beforeClose': function () { document.getElementById("<%=btnRedraw.ClientID%>").click(); }
                });
            });
        });
        /* Get the rows which are currently selected */
        function fnGetSelected(oTableLocal) {
            return oTableLocal.$('tr.hover');
        }
    }
    function pageLoad(sender, args) {
        $("#btnCreate").fancybox({
            'titleShow': false,
            'width': 600,
            'height': 460,
            'type': 'iframe',
            'transitionIn': 'elastic',
            'transitionOut': 'elastic',
            'closeClick': false,
            'helpers': {
                overlay: {
                    closeClick: false,
                    showEarly: false
                }
            },
            'overlayOpacity': 0.7,
            'enableEscapeButton': false,
            'showCloseButton': false,
            'beforeClose': function () { document.getElementById("<%=btnRedraw.ClientID%>").click(); }
        });
    }

</script>