Solved

jquery autocomplete in gridview , Asp.Net

Posted on 2010-11-19
4
2,268 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now