Solved

jquery autocomplete in gridview , Asp.Net

Posted on 2010-11-19
4
2,252 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
Comment Utility
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
Comment Utility
Try this out:

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

Expert Comment

by:Kumaraswamy R
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

6 Experts available now in Live!

Get 1:1 Help Now