使用javascript或jquery删除gridview的内容或行 [英] delete the contents or rows of gridview using javascript or jquery

查看:94
本文介绍了使用javascript或jquery删除gridview的内容或行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我在页面中使用网格视图,我想删除gridview的内容意味着使用javascript不需要的行我可以清除gridview的全部内容以及所有'td'' gridview使用单个jquery,如gridviewid.clear();行,但我不想清除所有内容,我想保留2行然后在2行之后什么额外的行在gridview我想删除使用javascript或jquery我尝试这样...



hi i am using a grid view in a page and i want to delete the contents of the gridview means the rows which are not needed using javascript i can clear the entire contents of gridview and also the all ''td'' of gridview using a single jquery like gridviewid.clear(); line but i do not want to clear all contents i want to keep the 2 rows then after 2 rows what ever extra rows are there in gridview i want to delete using javascript or jquery i tried like this...

for(var j =2 ;j<=rowscount;j++) {
    grd.deleteRow(3);}





但是我无法将其设置为无法工作我还试图通过使用以下代码来获取每个内容:





but i am not able to get this right its not working i had also tried to take each contents by using following code:

for(var j =2 ;j<=rowscount;j++) {
var lblid = "ctl00_ContentPlaceHolder1_gridColumn_ctl0"+ j +"_Label2";
    $(document.getElementById(lblid)).empty();
    var id = "ctl00_ContentPlaceHolder1_gridColumn_ctl0" + j + "_ddlcolumnname";
    var dropdown1 = document.getElementById(id);
    $(dropdown1).empty();
    var id2 = "ctl00_ContentPlaceHolder1_gridColumn_ctl0"+ j +"_ddlcolumndata";
    var dropdown2 = document.getElementById(id2);
    $(dropdown2).empty();
}





但是empty()函数正在清除页面整页中的所有内容变空并删除基于行的行在行号上我没有任何东西,因为gridview中的行号意味着我在gridview中有2个下拉列表和一个文本框,所以如何清除2行后的所有数据,请你帮助我在javascript或jquery编码...



提前感谢你!



but the empty() function is clearing all contents in page full page becomes empty and to delete the rows based on row number i do not have anything as row number in gridview means i have 2 dropdowns and a textbox within the gridview so how to i clear all the datas after 2 rows please can u help me the coding in javascript or jquery...

thanking you in advance!

推荐答案

(document.getElementById(lblid))。empty();
var id = ctl00_ContentPlaceHolder1_gridColumn_ctl0 + j + _ ddlcolumnname;
var dropdown1 = document.getElementById(id);
(document.getElementById(lblid)).empty(); var id = "ctl00_ContentPlaceHolder1_gridColumn_ctl0" + j + "_ddlcolumnname"; var dropdown1 = document.getElementById(id);


(dropdown1).empty();
var id2 = ctl00_ContentPlaceHolder1_gridColumn_ctl0 + j + _ ddlcolumndata;
var dropdown2 = document.getElementById(id2);
(dropdown1).empty(); var id2 = "ctl00_ContentPlaceHolder1_gridColumn_ctl0"+ j +"_ddlcolumndata"; var dropdown2 = document.getElementById(id2);


(dropdown2).empty();
}
(dropdown2).empty(); }





但是empty()函数正在清除页面整页中的所有内容变空并删除基于行的行在行号上我没有任何东西,因为gridview中的行号意味着我在gridview中有2个下拉列表和一个文本框,所以如何清除2行后的所有数据,请你帮助我在javascript或jquery编码...



提前感谢你!



but the empty() function is clearing all contents in page full page becomes empty and to delete the rows based on row number i do not have anything as row number in gridview means i have 2 dropdowns and a textbox within the gridview so how to i clear all the datas after 2 rows please can u help me the coding in javascript or jquery...

thanking you in advance!


这篇关于使用javascript或jquery删除gridview的内容或行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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