GridView中的自动完成jQuery(C#.net3.5) [英] autocomplete jquery in gridview (C#.net3.5)

查看:54
本文介绍了GridView中的自动完成jQuery(C#.net3.5)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用jquery在gridview(在带有C#的asp.net3.5中)中应用自动完成功能,并且此gridview位于ajax中

I want to apply autocomplete in gridview (in asp.net3.5 with C#) using jquery and this gridview is within the ajax

<update id=""UpdatePanel1"" runat=""server"><br" mode="hold" />    <ContentTemplate>.


为此,我正在< ItemTemplate>
中使用方法


For this i am using method within the <ItemTemplate>

$(document).ready(function(){
    $('[id$=txtItemCode]').autocomplete("SearchItem.aspx").result(function (event, data, formatted) {
        if (data) {
            alert('Value: '+ data[1]);
        }
        else {
            $('[id$=txtItemID]').val('-1');
        }
    });
    });


由于在gridview中,文本框ID为


since in gridview the textbox id is

<asp:TextBox id="txtItemCode" />

但是
在浏览器上,例如

but
on browser such as

<input type="textbox" id="ctl00_otherName_101txtItemCode" />


然后对于下一行,相同的文本框ID现在为


and then for the next row same textbox id is now

 <input type="textbox" id="ctl00_otherName_102txtItemCode" />
i tried
1. put this code within the <ItemTemplate>
2. <%= txtItemCode.ClientID %>
3. $("*[@id$=theGridId] input[@id$=txtItemCode]")
4. jQuery.expr[':'].asp = function(elem, i, match) {
    return (elem.id && elem.id.match(match[3] + "$"));
};
and $(":asp(txtItemCode)").autocomplete...
5.$('.txtItemCode').autocomplete("LookupCodes.aspx?type=IC", { mustMatch: true })


但是自动填充功能并非在所有情况下都有效
请帮助我.


but autocomplete does not work in all the cases
plz help me.

推荐答案

(document).ready(function(){
(document).ready(function(){


( [id
('[id


= txtItemCode]').autocomplete( SearchItem.aspx").result(函数(如果(数据){ alert(' 值:' + data [ 1 ]); } 其他 {
=txtItemCode]').autocomplete("SearchItem.aspx").result(function (event, data, formatted) { if (data) { alert('Value: '+ data[1]); } else {


这篇关于GridView中的自动完成jQuery(C#.net3.5)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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