Solved

jquery autocomplete in gridview , Asp.Net

Posted on 2010-11-19
4
2,290 Views
Last Modified: 2012-05-10
I want to populate autocomplete in gridview with jquery.

Please help me?
My Code:-
<link href="../Css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />

    <script src="../js/jquery-1.4.1.min.js" type="text/javascript"></script>

    <script src="../js/jquery.autocomplete.js" type="text/javascript"></script>

    <asp:MultiView ID="MultiView1" runat="server">
        <asp:View ID="View1" runat="server">
            <asp:TextBox ID="txtcertid123" runat="server" Text='<%# Eval("Cert_Id") %>'></asp:TextBox>
            <br />
            <asp:Label ID="Label1" runat="server" Text="Login Id :"></asp:Label>
            <asp:TextBox ID="txtloginid" runat="server"></asp:TextBox>
            &nbsp;<asp:Label ID="Label2" runat="server" Text="Branch :"></asp:Label>
            <asp:TextBox ID="txtbranch" runat="server"></asp:TextBox>
            &nbsp;<asp:Label ID="Label18" runat="server" Text="Username :"></asp:Label>
            <asp:TextBox ID="txtusername0" runat="server"></asp:TextBox>
            &nbsp;<asp:Label ID="Label17" runat="server" Text="Pincode :"></asp:Label>
            <asp:TextBox ID="txtpincode" runat="server"></asp:TextBox>
            &nbsp;<br />
            <asp:Label ID="Label11" runat="server" Text="Status :"></asp:Label>
            <asp:CheckBox ID="chkstatus" runat="server" />
            <br />
            <br />
            <asp:GridView ID="gvodinuserdtl" runat="server" AutoGenerateColumns="False" Width="95%"
                OnDataBound="gvodinuserdtl_DataBound" OnRowDataBound="gvodinuserdtl_RowDataBound">
                <Columns>
                    <asp:TemplateField Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblid" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Segment">
                        <ItemTemplate>
                            <asp:DropDownList ID="ddlsegment" runat="server">
                            </asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Neat Id">
                        <ItemTemplate>
                            <asp:TextBox ID="txtneatid" runat="server" Text='<%# Eval("Neat_id") %>'></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Branch Id">
                        <ItemTemplate>
                            <asp:TextBox ID="txtbranchid" runat="server" Text='<%# Eval("Branch_Id") %>'></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Ctcl Id">
                        <ItemTemplate>
                            <asp:TextBox ID="txtctcl_Id" runat="server" Text='<%# Eval("Ctcl_Id") %>'></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <br />
            <asp:GridView ID="gvodinusercertdtl" runat="server" AutoGenerateColumns="False" Width="45%"
                OnRowDataBound="gvodinusercertdtl_RowDataBound">
                <Columns>
                    <asp:TemplateField Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblid" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Certificate">
                        <ItemTemplate>
                            <input id="txtcertid" type="text" name="txtcertid" runat="server" value='<%# Eval("Cert_Id") %>' />
                            <script type="text/javascript">
                                $(document).ready(function() {
                                    $("#<%=txtcertid.ClientID%>").autocomplete('../Autocomplete.ashx');
                                });      
    </script>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <br />
            <asp:Button ID="btnsave" runat="server" Text="Save" Width="65px" OnClick="btnsave_Click" />
            &nbsp;<asp:Button ID="btnupdate" runat="server" Text="Update" Visible="False" Width="65px"
                OnClick="btnupdate_Click" />
            <asp:LinkButton ID="lnkbtnlisting" runat="server" OnClick="lnkbtnlisting_Click">Listing</asp:LinkButton>
        </asp:View>
        <asp:View ID="View2" runat="server">
            <asp:Label ID="Label16" runat="server" Text="Login Id :"></asp:Label>
            <asp:TextBox ID="txtloginidsearch" runat="server"></asp:TextBox>
            &nbsp;&nbsp;<asp:Label ID="Label13" runat="server" Text="Branch :"></asp:Label>
            &nbsp;<asp:TextBox ID="txtbranchsearch" runat="server"></asp:TextBox>
            <asp:Label ID="Label14" runat="server" Text="Username :"></asp:Label>
            <asp:TextBox ID="txtusernamesearch" runat="server"></asp:TextBox>
            &nbsp;<asp:Button ID="btnsearch" runat="server" Text="Search" OnClick="btnsearch_Click" />
            <asp:LinkButton ID="lnkbtnaddnew" runat="server" OnClick="lnkbtnaddnew_Click">Add New</asp:LinkButton>
            <br />
            <asp:GridView ID="gvcontactlist" runat="server" AutoGenerateColumns="False" Width="95%"
                OnRowCommand="gvcontactlist_RowCommand" OnRowEditing="gvcontactlist_RowEditing">
                <Columns>
                    <asp:TemplateField Visible="false">
                        <ItemTemplate>
                            <asp:Label ID="lblid" runat="server" Text='<%# Eval("Odin_User_id") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="LoginId">
                        <ItemTemplate>
                            <asp:Label ID="lblloginid" runat="server" Text='<%# Eval("Login_id") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Branch">
                        <ItemTemplate>
                            <asp:Label ID="lblbranch" runat="server" Text='<%# Eval("branchcode") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="User Name">
                        <ItemTemplate>
                            <asp:Label ID="lblusername" runat="server" Text='<%# Eval("user_name") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Pincode">
                        <ItemTemplate>
                            <asp:Label ID="lblpincode" runat="server" Text='<%# Eval("pincode") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkedit" runat="server" Text="edit" CommandName="edit" CommandArgument='<%# Eval("Odin_User_id") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <br />
        </asp:View>
    </asp:MultiView>

I am getting  this error:-

Compiler Error Message: CS0103: The name 'txtcertid' does not exist in the current context

Source Error:

 

Line 73:                             <script type="text/javascript">
Line 74:                                 $(document).ready(function() {
Line 75:                                     $("#<%=txtcertid.ClientID%>").autocomplete('../Autocomplete.ashx');
Line 76:                                 });      
Line 77:     </script>
 

Source File: d:\UITS\UITS.UI\Pages\Odin_UserId_Master.aspx    Line: 75



0
Comment
Question by:dynamicweb09
4 Comments
 
LVL 7

Accepted Solution

by:
dxdinh earned 250 total points
ID: 34177842
Can you textbox server control instead of input control runat server

Change this

<input id="txtcertid" type="text" name="txtcertid" runat="server" value='<%# Eval("Cert_Id") %>' />

to
<asp:TextBox ID="txtcertid" runat="server" Text='<%# Eval("Cert_Id") %>'></asp:TextBox>
0
 
LVL 14

Assisted Solution

by:CtrlAltDl
CtrlAltDl earned 250 total points
ID: 34189784
Try this out:

$(document).ready(function() {
    $('[id$=txtcertid]').autocomplete('../Autocomplete.ashx');
});  
0
 
LVL 29

Expert Comment

by:Kumaraswamy R
ID: 34387742
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question