Solved

jquery autocomplete in gridview , Asp.Net

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

778 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