Hi All.
I am using a dropdown list for states and a textbox for cities which have a Autocomplete extender to populate cities based on state selected in the dropdownlist. from webservice method I am trying to call a function from datalayer.
But its not working for me.
Please find below code
.aspx
<asp:DropDownList ID="ddlState" runat="server" AutoPostBack="true"
OnSelectedIndexChanged ="State_OnSelectedIndexChanged" style="width: 205px;"></asp:DropDownList>
asp:TextBox ID="txtCity" runat="server" style="width: 200px;"></asp:TextBox><asp:AutoCompleteExtender ID="aceShipCity" runat="server" TargetControlID="txtCity"
CompletionInterval="100" CompletionSetCount="10" MinimumPrefixLength="1"
EnableCaching="true" ServiceMethod="GetCities" UseContextKey="true"
FirstRowSelected="false"></asp:AutoCompleteExtender>.aspx.cs
protected void State_OnSelectedIndexChanged(object sender, EventArgs e)
{
try
{
aceCity.ContextKey = State.SelectedValue;
}
catch (Exception ex)
{
}
}
public static List<string> GetCities(string strPrefixText, string strStateContextKey)
{
List<string> lstCities = new List<string>();
try
{
//get cities from the method
DataTable dtTempCities = new DataTable();
CO objCO = new CO();
dtTempCities = objCO.GetCities(strPrefixText, strStateContextKey);
//store the datatable rows as list<string>
if (dtTempCities.Rows.Count > 0)
{
for (int i = 0; i < dtTempCities.Rows.Count; i++)
{
lstCities.Add(dtTempCities.Rows[i]["Cities"].ToString());
}
}
else
{
//no records found
}
}
catch (Exception ex)
{
//do nothing for now
}
return lstCities;
}
Any help would be appreciated