Java中的Asp:GridView DataBind [英] Asp:GridView DataBind in Javascript

查看:108
本文介绍了Java中的Asp:GridView DataBind的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在javascript中将gridview数据绑定为"datasource = null".

Hi, I want to databind gridview as "datasource = null" in javascript. How to do this?

推荐答案

Datagrid呈现为表格.使用datagrid查看任何页面的源代码并查看.

通过Javascript进行任何更改时,都是在客户端进行的,因此您需要在基本html级别上工作.

试试:
Datagrid is rendered as a table. Do viewsource of any page with datagrid and see.

When you are making any change via Javascript, you are making it client side and thus you need to work at basic html level.

Try:
//EmptyHTMLText is whatever empty html based text you would like to set
document.getElementById("gvTest").outerHTML = EmptyHTMLText;


您好..

我认为您想使用javascript清除数据..在这里看看..
Hi there..

As I think that you wanna clear your data using javascript.. Just have a look here.. http://weblogs.asp.net/ahmedmoosa/archive/2010/10/30/bind-gridview-using-jquery.aspx[^]
I hope this will help you.
All the best..


尝试一下.

后台代码

Try this.

Code-behind

protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack)
    {
        string script = String.Format("javascript:return DeleteGridView('{0}');", gvAttribute.ClientID);
        txtPercentage.Attributes.Add("onkeydown", script);
    }
}



Javascript



Javascript

function DeleteGridView(grid_id) {
    var grid = document.getElementById(grid_id);
    if (grid.parentNode) {
        grid.parentNode.removeChild(elem);
    }
    return false;
}


这篇关于Java中的Asp:GridView DataBind的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆