<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="TEST2.index" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" type="text/css" href="Styles/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="Styles/themes/icon.css">
<style type="text/css">
html,body{margin:0px;padding:0px;font-size:12px;height:100%;}
#login{ text-align:center;}
#login h3{color:#1776CA;font-size:25px;}
#search{ background:#FFF0F5 ; border:1px #A9CAE5 solid; height:40px; padding:5px; line-height:40px; margin-top:10px; width:980px; text-align:left;margin:auto;}
#main{ margin-left:auto;margin-right:auto; width:990px; margin-top:10px;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="header">
<div id="login">
<h3>规划项目</h3>
</div>
<div id="search">
<table width="980" cellpadding="0px" cellspacing="0px" border="0px">
<tr>
<td width="70">所在地区:</td>
<td width="120"><asp:DropDownList ID="DropDownList1" runat="server" Width="120">
<asp:ListItem Selected="True">全省</asp:ListItem>
<asp:ListItem>杭州</asp:ListItem>
<asp:ListItem>金华</asp:ListItem>
</asp:DropDownList>
</td>
<td width="50"> </td>
<td width="80">项目名称:</td>
<td width="150">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
<td width="50"> </td>
<td width="80">
<asp:Button ID="Button1" runat="server" Text="搜索"/></td>
<td width="80"><asp:Button ID="Button2" runat="server" Text="导出" /></td>
<td width="300"> </td>
</tr>
</table>
</div>
<div id="main">
<table id="dg" class="easyui-datagrid" >
<thead>
<tr>
<th field="city" width="200">市</th>
<th field="xian" width="200">县</th>
<th field="xmmc" width="200">项目名称</th>
<th field="ghmc" width="200">规划名称</th>
<th field="xmlx" width="200">项目类型</th>
<th field="qqjzqk" width="230" align="center">前期进展情况</th>
</tr>
</thead>
</table>
</div>
<script type="text/javascript" src="Scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="Scripts/jquery.easyui.min.js"></script>
<script src="Scripts/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
start();
$("#Button1").click(function () {
search();
});
});
$("#dg").datagrid(
{
url: 'DataHandler1.ashx?city1=hangzhou &xm1=hangzhou',
// url: 'DataHandler1.ashx?city1='+city+'&xm1='+xm,
width: 990,
pageNumber: 1,
pageSize: 20,
pageList: [20, 40, 60],
height: 400,
fitColumns: true,
rownumbers: true,
pagination: true,
collapsible: true,
sortName: 'no',
sortOrder: 'asc'
}
)
function start() {
}
function search() {
var ddl = document.getElementById("DropDownList1")
var index = ddl.selectedIndex;
var city = ddl.options[index].value;
var xm = $('#TextBox1').val();
$("#dg").datagrid(
{
url: 'DataHandler1.ashx?city1=hangzhou &xm1=hangzhou',
// url: 'DataHandler1.ashx?city1='+city+'&xm1='+xm,
width: 990,
pageNumber: 1,
pageSize: 20,
pageList: [20, 40, 60],
height: 400,
fitColumns: true,
rownumbers: true,
pagination: true,
collapsible: true,
sortName: 'no',
sortOrder: 'asc'
}
)
}
</script>
</form>
</body>
</html>
如果 $("#dg").datagrid那段代码放到外面能显示数据。但是如果放到方法start()里面,DataHandler1.ashx能读取到数据,但是表格里显示不出来。search方法里一样。有人碰到过一样的情况吗
放到外面
放到方法里面
求好心人帮忙。。正在实习,搞不出来烦躁。。。
4 个解决方案
#1
放到Start函数里面,你初始化的时候调用了吗?
#2
$("#dg").datagrid这句是调用吗- -
#3
有人帮忙吗。。。
#4
已解决。貌似.net里的按钮不行,会自动刷新,,用了input的按钮就可以了
#1
放到Start函数里面,你初始化的时候调用了吗?
#2
$("#dg").datagrid这句是调用吗- -
#3
有人帮忙吗。。。
#4
已解决。貌似.net里的按钮不行,会自动刷新,,用了input的按钮就可以了