I want to apply autocomplete in gridview (in asp.net3.5 with C#) using jquery and this gridview is within the ajax update panel<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>.
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');
}
});
});
since in gridview the textbox id is <asp:TextBox id="txtItemCode" /> but
on browser such as <input type="textbox" id="ctl00_otherName_101txtItemCode" />
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.
|