Click here to Skip to main content
15,039,145 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all

I want to fill all employees name in my employee table according to the text typed in textbox

i uses auto fill extender
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True">
<cc1:AutoCompleteExtender  runat="server" ID="autoComplete1" TargetControlID="TextBox1"
ServiceMethod="GetEmpDetails1" ServicePath="~/PayRoll/webservice/hr1service.asmx" MinimumPrefixLength="1"

and in web service the method

    public string GetEmpDetails1(string as_EmpName, int count)
        using (AdminBusinussFacade.FacadeCommon fum = new AdminBusinussFacade.FacadeCommon())
            DataSet ds_empsearch = fum.ff_fillddlRelation("", as_EmpName,"","Webser_search", "", "");

            DataTable dt = ds_empsearch.Tables[0];

            string s = "";

            for (int i = 0; i < dt.Rows.Count; i++)
                s = s + dt.Rows[i][0].ToString() + "/" + dt.Rows[i][1].ToString() +" "+ dt.Rows[i][2].ToString()+" "+dt.Rows[i][3].ToString()+" "+"["+dt.Rows[i][4].ToString()+"]" + " Branch" + "/";

            return s;

But it doesnt works
Plz give a solution for this

Thanks in Advance


Updated 10-Aug-11 19:45pm

The webservice is supposed to return an array of strings, not a string. In future, don't say 'it does not work', tell us what it does, as well as what you expect it to do.
Create a Webservice first i am writing the code in VB.Net

Protected LoginCon As System.Data.SqlClient.SqlConnection
    <webmethod()> _
   Public Function RetCityNames(ByVal prefixText As String) As String()
        Dim count As Integer = 10
        Dim Con As String = System.Web.Configuration.WebConfigurationManager.ConnectionStrings("CCon").ConnectionString
        LoginCon = New System.Data.SqlClient.SqlConnection(Con)
        Dim sql As String = "Select distinct CityName from CityMaster Where CityName like @prefixText"
        Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, LoginCon)
        da.SelectCommand.Parameters.Add("@prefixText", System.Data.SqlDbType.VarChar, 50).Value = prefixText + "%"
        Dim dt As New System.Data.DataTable
        Dim items(dt.Rows.Count - 1) As String
        Dim i As Integer
        For Each dr As System.Data.DataRow In dt.Rows
            items.SetValue(dr("CityName").ToString(), i)
            i = i + 1
        Return items
    End Function

next in Textbox UI
<cc1:AutoCompleteExtender ID="txtCityName_AutoCompleteExtender"  runat="server"
                                       DelimiterCharacters="" Enabled="True" ServiceMethod="RetCityNames" ServicePath="CityService.asmx"
                                       MinimumPrefixLength="3" TargetControlID="txtCityName">


As per table and Field name u change it , it will work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900