[RESOLVED] How to display (old values) text automatically in text box somthing like MS-Excel cell

Hello,

Is there a way in .net to display the text automatically when i type the first letter or word in a text box?

I am looking for something like MS-Excel.. In MS-Excel, if the first word is given, automatically it displays the remaining texts, only if values are given previously.

Thanks

Nick

 

you may use ajaxcontroltoolkit control (Auto Complete).

e.g: http://www.asp.net/ajax/ajaxcontroltoolkit/samples/autocomplete/autocomplete.aspx


i tried retriving values from the database but i am not getting the expected out

could you please help me?

following i smy code

Public Function Getdata1(ByVal text As String, ByVal count As Integer) As String()
        Dim dt As New DataTable
        Dim sql As String = "SELECT ID FROM dbo.products"
        dt = MPClass.FillTable(sql)


          Dim items As String() = New String(dt.Rows.Count - 1) {}
        Dim i As Integer = 0
        For Each dr As DataRow In dt.Rows
            items.SetValue(dr("ID").ToString(), i)
            i += 1
        Next
        Return items

    End Function



Public Shared Function FillTable(ByVal sql As String) As DataTable
        Dim conn As SqlConnection = MPClass.GetConnection()
        Dim cmd As New SqlCommand("", conn)
        Dim da As New SqlDataAdapter("", conn)
        Dim ds As New DataSet
        da.SelectCommand.CommandText = sql
        da.Fill(ds)
        Return ds.Tables(0)
    End Function



<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:ScriptManager id="ScriptManager1" runat="server">     
        </asp:ScriptManager>
        <asp:AutoCompleteExtender
        runat="server"
        ID="AutoCompleteExtender"
        TargetControlID="TextBox1"
        ServiceMethod="Getdata1"
        MinimumPrefixLength="1"
               >
        </asp:AutoCompleteExtender>

I don't see the ServicePath attribute  for the AutoCompleteExtender.

Here's a nice beginner example

http://www.davidhayden.com/blog/dave/archive/2007/10/22/ASPNETAJAXAutoCompleteExampleUsingAutoCompleteExtenderControl.aspx

Also you can try JQuery AutoComplete....

http://docs.jquery.com/Plugins/autocomplete

And to call WebMethods from JQuery....

http://www.intstrings.com/ramivemula/articles/jquery-post-get-request-to-wcf-service-in-asp-net-mvc/

In the above resoource, you can write your database logic in the WCF service....

Thanks.

I tried the way mentioned in the link above i am not getting the expected output

I have coopied the code from the  below mentioned link and still didnt get the expected op

http://www.aspsnippets.com/Articles/ASP.Net-AJAX-Control-Toolkit-AutoCompleteExtender-without-using-Web-Services.aspx

could you please help me?

My code is given below


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

 

 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

 <asp:ScriptManager id="ScriptManager1" EnablePageMethods = "true" runat="server"> </asp:ScriptManager>

 <cc1:AutoCompleteExtender ID="AutoCompleteExtender" TargetControlID="TextBox1" ServiceMethod="SearchCustomers"
  MinimumPrefixLength="2" CompletionInterval="100" EnableCaching="false"
  CompletionSetCount="10" runat="server" FirstRowSelected = "false" >
</cc1:AutoCompleteExtender>

 

 
Imports System.Data.SqlClient
Imports System.Collections.Generic

 <System.Web.Script.Services.ScriptMethod(), _
    System.Web.Services.WebMethod()> _
    Public Shared Function SearchCustomers(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
        Dim conn As SqlConnection = New SqlConnection
        conn.ConnectionString = ConfigurationManager _
             .ConnectionStrings("DEV_ADD1ConnectionString").ConnectionString
        Dim cmd As SqlCommand = New SqlCommand
        cmd.CommandText = "select ProdID from dbo.produ where" & _
            " ProdID like @SearchText + '%'"
        cmd.Parameters.AddWithValue("@SearchText", prefixText)
        cmd.Connection = conn
        conn.Open()
        Dim customers As List(Of String) = New List(Of String)
        Dim sdr As SqlDataReader = cmd.ExecuteReader
        While sdr.Read
            customers.Add(sdr("ProdID").ToString)
        End While
        conn.Close()
        Return customers
    End Function

conenction string is working fine

pls help me

thanks
nick

Hi nicklibee,

Please check the following aspects:

  • The server code is being hit for theweb service?
  • Your query is being executed andreturning results?
  • Your items array is being populatedcorrectly?

    If "nothing" is that none of the above is happening, I would start checking that there are no javascript errors on the page and that your AutoComplete extender is rendering correctly (examine the page controls in a trace).

  • Please check the following link:

    http://www.c-sharpcorner.com/UploadFile/munnamax/AutocompleteExtender08062007113854AM/AutocompleteExtender.aspx

    http://www.java2s.com/Tutorial/ASP.NET/0400__Ajax/UsingtheAutoCompleteExtenderwithaWebServiceMethod.htm

    http://stackoverflow.com/questions/730937/ajax-autocompleteextender-isnt-working-web-service-works

    thoughts on "[RESOLVED] How to display (old values) text automatically in text box somthing like MS-Excel cell "

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>