Click here to Skip to main content
16,014,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i am using asp.net 3.5 ,visualstudio 2008 ,sqlserver2008 using webservice
In my project Autocomplete extender for using admission no. get in our database it was stored in 121010001/002
121020001/003
121020002/002
121010002/001
111020002/001
111020001/003
111010001/001 in this format. but i have get in autocomplete was in this format

60505000.5
40340000.333333336
60510001
121010002
111020002
37006667
111010001

i don't know the problem pls help me to correct the problem.

In stored procedure get records are correct format (that is 121010001/002
121020001/003
121020002/002
121010002/001
111020002/001
111020001/003
111010001/001)

i have use webservice in service.asmx and the methods are written in service.cs i am just call aspx page with ajax autocompleteExtender control and servicepath was service.asmx and servicemethod are written webmethod in service.cs page to call th function.

sample code here

C#
<asp:TextBox ID="txtAdmisssionNo" runat="server" Onkeypress="return allownumbers(event)" MaxLength="15"></asp:TextBox>
                 <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtAdmisssionNo"
                                                ServicePath="~/Service.asmx" MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1"
                                                CompletionInterval="100" ServiceMethod="getAdmissionNo" OnClientPopulating="ShowProcessImage"
                                                OnClientPopulated="HideProcessImage" >


                    </asp:AutoCompleteExtender>



service.cs page code here
C#
[WebMethod]
   public List&lt;string&gt; getAdmissionNo(string prefixText)
   {
       SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.AppSettings[&quot;MyCon&quot;].ToString());
       sqlConnection.Open();
       //SqlCommand sqlCommand = new SqlCommand(&quot;select ISNULL(AdmissionNo,ApplicationID)AdmissionNo from OA_ADM_tblAdmission_AdmissionDetails  where AdmissionNo like @Name+'%' OR ApplicationID like @Name+'%' &quot;, sqlConnection);
       SqlCommand sqlCommand = new SqlCommand(&quot;select ISNULL(AdmissionNo,ApplicationID)AdmissionNo from OA_ADM_tblAdmission_AdmissionDetails  where AdmissionNo like @Name+'%'&quot;, sqlConnection);
       sqlCommand.Parameters.AddWithValue(&quot;@Name&quot;, prefixText);
       SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
       DataTable dt = new DataTable();
       sqlDataAdapter.Fill(dt);
       List&lt;string&gt; AdmissionNos = new List&lt;string&gt;();

       for (int i = 0; i &lt; dt.Rows.Count; i++)
       {
           AdmissionNos.Add(dt.Rows[i][&quot;AdmissionNo&quot;].ToString());
       }
       return AdmissionNos;

   }
Posted
Updated 18-Jan-12 23:23pm
v4
Comments
Jephunneh Malazarte 19-Jan-12 2:03am    
can you please rearrange your content? kind of hard to read.
Anuja Pawar Indore 19-Jan-12 5:23am    
Added proper pre tag. Removed extra pre tag

For this your web service should return the divided values

change your code link this

C#
for (int i = 0; i &lt; dt.Rows.Count; i++)
       {
          string s=dt.Rows[i]["AdmissionNo"].ToString();
           
           AdmissionNos.Add( Convert.ToDouble(s.Split('/')[0]) / Convert.ToDouble(s.Split('/')[1]));
       }


Hope this will give you an IDEA.
 
Share this answer
 
AdmissionNos.Add(dt.Rows[i][AdmissionNo].ToString());
change to

AdmissionNos.Add("\""+dt.Rows[i]["AdmissionNo"].ToString()+ "\"");

or
AdmissionNos.Add("'" + dt.Rows[i]["AdmissionNo"].ToString() + "'");
 
Share this answer
 
v2

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