搜索选项使用文本框按键进行gridview,使用jquery在C#ASP.NET中进行分页? [英] Search option using textbox key press for gridview with paging in C# ASP.NET using jquery?

查看:69
本文介绍了搜索选项使用文本框按键进行gridview,使用jquery在C#ASP.NET中进行分页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



使用文本框按键搜索选项按下网格视图,使用jquery在c#asp.net中进行分页?



我的搜索代码运行正常,没有分页,但是当我设置允许分页为真时,

它只搜索了5行。



我的搜索代码没有使用分页运行。

i使用输入类型文本:



Hello,

Search option using textbox key press for gridview with paging in c# asp.net using jquery?

My search code is running fine without paging but when i set allow paging true so,
It was searching only 5 rows.

My search code not running with paging.
i have use input type text:

<input name="search" type="text" id="search" value="" autocomplete="off" onkeyup="Search_Gridview(this,'gvEmpSkillDetails')" class="form-control" placeholder="Search">





用于搜索。



请帮帮我。



先谢谢。



Ankit Agarwal


我尝试了什么:



< script type =text / javascript>

function Search_Gridview (strKey,strGV){

var strData = strKey.value.toLowerCase()。split();

var tblData = document.getElementById(strGV);

var rowData;

for(var i = 1;我< tblData.rows.length; i ++){

rowData = tblData.rows [i] .innerHTML;

var styleDisplay ='none';

for(var j = 0; j< strData.length; j ++){

if(rowData.toLowerCase()。indexOf(strData [j])> = 0)

styleDisplay = '';

else {

styleDisplay ='none';

休息;

}

}

tblData.rows [i] .style.display = styleDisplay;

}

}

< / script>



for searching.

Please help me.

Thanks in Advance.

Ankit Agarwal

What I have tried:

<script type="text/javascript">
function Search_Gridview(strKey, strGV) {
var strData = strKey.value.toLowerCase().split(" ");
var tblData = document.getElementById(strGV);
var rowData;
for (var i = 1; i < tblData.rows.length; i++) {
rowData = tblData.rows[i].innerHTML;
var styleDisplay = 'none';
for (var j = 0; j < strData.length; j++) {
if (rowData.toLowerCase().indexOf(strData[j]) >= 0)
styleDisplay = '';
else {
styleDisplay = 'none';
break;
}
}
tblData.rows[i].style.display = styleDisplay;
}
}
</script>

推荐答案

因为您使用javascript查询/过滤屏幕上显示的数据(gridview),显然,如果条件,它将仅根据你的过滤屏幕上可用的数据(gridivew)。

这个我javascript如何工作



当你使用分页例如每条10条记录页面),服务器将只在 10条记录传输到网络浏览器.w3schools.com / html / html_tables.asp> HTML表格 [ ^ ]格式,您的代码将只查询10条记录,而不是整个数据集。

如果要过滤整个数据,则应删除分页,以便整个数据集将以HTML表格格式传输到浏览器。



您的Javascript代码可以控制 DOM [ ^ ]只有,而不是服务器数据,如果你想通过使用Javascript对服务器数据进行过滤,那么你将不得不使用 JQuery AJAX [ ^ ]以异步方式获取数据并基于 JSON [ ^ ]结果数据,建立 HTML表动态 [ ^ ]。



这是你如何解决你的问题issue。
Since you are using javascript to query/filter the data which is displaying on the screen(gridview) , Obviously it will filter only the data available on the screen(gridivew) based on your if conditions.
This is how javascript works

When you are using pagination (eg 10 records per page), The Server will transfer only 10 records to the web browser in an HTML Table[^] format and you code will query that 10 records only, not the entire dataset.
if you want to filter the entire data, you should remove the pagination, so that the whole dataset will be transferred to the browser in an HTML Table format.

Your Javascript code has the Control over DOM [^]only, not to the server data, if you want to do the filtering over server data by using Javascript then you will have to use JQuery AJAX[^] to get the data asynchronously and based on the JSON [^] result data, build the HTML table dynamically[^].

This is how you can resolve your issue.


请参阅以下链接以获取帮助。





使用ASP中的jQuery在TextBox KeyPress上搜索GridView。净 [ ^ ]



在ASP.Net&#8211;中使用jQuery在TextBox KeyPress上搜索GridView。 DTKit [ ^ ]
Please see the links below for your help.


Search GridView with Paging on TextBox KeyPress using jQuery in ASP.Net[^]

Search GridView with Paging on TextBox KeyPress using jQuery in ASP.Net &#8211; DTKit[^]


这篇关于搜索选项使用文本框按键进行gridview,使用jquery在C#ASP.NET中进行分页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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