Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am using ajaxcontrol toolkit Autocomplete extender asp.net 2.0 in my application.

For eg. i have dsplayed the country name in my textbox based on the search fetching the records from the database. i need to get the country id value to insert the database.
Posted
Updated 10-Aug-10 19:53pm
v3

Did you mean to post this as a stand alone question? It seems rather incomplete - did you mean to post it as a question / comment to someone else's article / answer / comment?
If so, please delete this question and post it in a more sensible place!
If not, please edit you question and clarify what you are trying to do.
 
Share this answer
 
Its better to write yourself a new AutoComplete using Ajax and Handler file. because AjaxAutoExtentder need to match the return type and parameter name and type. Check the link to read more ASP.Net AutoComplete Demonstration[^]. if you need customization its better to write yourself. Style effect can add through JQuery.
 
Share this answer
 
i got the solution....

Webservice Method
==================
<pre lang="msil">[WebService(Namespace = quot;http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]</pre>

[WebMethod]

public string[] AutoComplete_Software(string prefixText)
{
DataSet dtst = new DataSet();
SqlConnection sqlCon = new SqlConnection(ConfigurationManager.AppSettings["InventoryCon"]);
string strSql = "Select Software_ID,Software_Name from Softwares where Software_Name like '" + prefixText + "%' ";
SqlCommand sqlComd = new SqlCommand(strSql, sqlCon);
sqlCon.Open();
SqlDataAdapter sqlAdpt = new SqlDataAdapter();
sqlAdpt.SelectCommand = sqlComd;
sqlAdpt.Fill(dtst);
string[] cntName = new string[dtst.Tables[0].Rows.Count];
int i = 0;
try
{
foreach (DataRow rdr in dtst.Tables[0].Rows)
{
cntName.SetValue(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(rdr["Software_Name"].ToString(),rdr["Software_ID"].ToString()),i);
i++;
}
}
catch { }
finally
{
sqlCon.Close();
}
return cntName;
}

Default.aspx
============
<pre lang="xml"><script type="text/javascript">

function GetSoftwareID(sender, e )
{
var Software_idValue = $get('<%= Software_idValue.ClientID %>');
Software_idValue.value = e.get_value();
}</pre>


<pre lang="xml"><pre lang="xml">asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
<Services >
<asp:ServiceReference Path="AutoComplete.asmx"/>
</Services>
</asp:ScriptManager></pre></pre>


<pre lang="xml"><asp:TextBox ID="txtSoftwareName" runat="server" Font-Names="Tahoma"
Width="200px" AutoPostBack="True"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtSoftwareName"
ServiceMethod="AutoComplete_Software" ServicePath="AutoComplete.asmx" OnClientItemSelected ="GetSoftwareID"
CompletionInterval="50" CompletionSetCount="10" MinimumPrefixLength="1" ContextKey="Software_ID">
</cc1:AutoCompleteExtender><asp:HiddenField id="Software_idValue" Runat="server" /></pre>
<pre lang="C++"><asp:Label id="lblSoftware_id" runat="server" /></pre>


dafault.aspx.cs
===============
in button click event

&lt;pre lang=&quot;midl&quot;&gt;lblSoftware_id.Text = Software_idValue.Value;&lt;/pre&gt;</pre>
 
Share this answer
 

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