各位大侠,我想实现在客户端页面上的button ,不是asp:button,触发onclick事件以后,显示gridview,开始的时候gridview是隐藏的,并且gridview没有绑定数据源,显示以后开始绑定数据源,并显示数据
解决方案 »
- 小白求助,在ASP.NET的project中,两个Class之间不能相互引用
- 企业库unity问题,请教
- error: 80040154
- 有没不忙的.net高手?
- 如果打回车来更新模板列中的TEXTBOX?
- 一个奇怪的ajax问题?
- 如何在代码中访问web.config中的location节?
- asp.net 2.0 新增的控件treeview 怎么用,以前的javascript子结点父结点选中联动关系怎么不能用了
- 一个asp.net的编译错误“无法识别的转义序列”,紧急求助!!!???
- 请教asp.net mvc缓存的一个问题
- Gridview 统计问题,在线等,会的朋友麻烦帮个忙
- 有关中英双文网站的问题
开始gridview给个display:none;点击button时,再显示出来
你的按钮执行:
document.getElementById("<%=button1.ClientID%>").click();
就行了~
用ajax获取数据 构建table 也就不需要gridview了
或AJAX中绑定数据到gridview
或updatepanel document.getElementById("btN").click()
我不想用updatepanel,数据量一大就显示很慢呀
我想用ajax中绑定数据到gridview,大侠能否给个例子,谢谢
那样做页面有刷新
GridView的位置,用css设置GridView显示在客户端就是个Table
能给个例子吗,我用百度查了两天了也没有查到呀
我不想用微软的updatepanel,那样速度太慢了呀
然后重写页面的Render方法,控制页面上只有GridView的展现
在用Ajax的方式请求该页
这样只是用GridView显示数据,其所有服务器端事件将失效!我这有个类似的例子,把列表换成GridView即可,希望对你有帮助http://www.51aspx.com/CV/AjaxAccessGuestbook/
页面:<div id="testDiv"> </div> //function GetStr()
{
$('#testDiv').innerTHML = test.TestStr().value;
}后台:load事件中注册ajax
[ajax.AjaxMothed]
pulic string TestStr()
{
DataSet ds = ...//数据集
string str = "<table border='0'> <tr><td>测试</td></tr>";
foreach(DataRow dr in ds.table[0].rows)
{
str +="<tr><td>"+dr["显示的数据"]+"</td></tr>";
}
str +="</table>";
returen str;
}
页面:<div id="testDiv"> </div> //function GetStr()
{
$('#testDiv')html(test.TestStr().value);
}后台:load事件中注册ajax
[ajax.AjaxMothed]
pulic string TestStr()
{
DataSet ds = ...//数据集
string str = "<table border='0'> <tr><td>测试</td></tr>";
foreach(DataRow dr in ds.table[0].rows)
{
str +="<tr><td>"+dr["显示的数据"]+"</td></tr>";
}
str +="</table>";
returen str;
}
不过是调后台方法而已<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function btnInvoke_onclick()
{
//PageMethods 调用页面方法代理时统一的前缀为PageMethods
//即语法为:
//PageMethods.[MethodName](param1, param2,..., callbackFunction);
PageMethods.SayHelloFromPage("click me !", onSayHelloSucceeded);
}
function onSayHelloSucceeded(result) {
alert(result+"成功了");
}
//还可以用另一种调用方式 AjaxPro
</script>
</head>
<body>
<form id="form1" runat="server">
<!--ScriptManager 的 EnablePageMethods="true" 不可缺少 -->
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
</asp:ScriptManager>
<button id="f" onclick="btnInvoke_onclick();">me click</button>
</form>
</body>
</html>//后台方法
[WebMethod]
public static string SayHelloFromPage(string name)
{
return string.Format("Hello {0}!", name);
}
<script type="text/javascript">
$(function() {
$('#Button1').click(function() {
$('#GridView1').show();
$('#Hidden1').val("aaa");
form1.submit();
});
})
</script>HTML代码:<form id="form1" name="form1">
<input id="Hidden1" name="Hidden1" type="hidden" />
<input id="Button1" type="button" value="button" />
<asp:GridView ID="GridView1" runat="server" style="display:none;">
</asp:GridView>
</form>
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Request.Params["Hidden1"]))
{
if (Request.Params["hidLogOut"].ToString() == "aaa")
{
BindGirdDate(); //绑定girdview数据方法
}
}
}