$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
DropDownList Client Side Data Binding in ASP.NET
Home > How to > DropDownList Client Data Binding

DropDownList control of KT.UI SDK supports users to invoke and use mature WebServiceSettings web interface handling technique to bind data in client side. Unlike the complex options for binding to all ASP.NET 2.0 DataSource components in server side, including SqlDataSource, EntityDataSource, and XmlDataSource, DropDownList component simplifies the process and operation for client side data binding by using the mentioned WebServiceSettings web data managing skill.
Some users may be confused about what the WebServiceSettings technique is. Here, we can give you the brief explanations. Using KT.UI DropDownList client side data binding WebServiceSettings control, users are capable of writing and adding a certain method within WebService and then calling this method within ASPX application to reach the data binding goal.

Example ASP.NET & C# Codes for Client Side Data Binding

With the support of WebServiceSettings technique, users can simply and precisely set data binding values in client side by using KT.UI DropDownList component within both web ASP.NET and C#.NET programming projects. We mainly help users with client side data binding from following two parts: ASPX demo codes for DropDownList client side data binding and sample C# codes on DropDownList client side data binding.

Demo ASPX Codes for Client Side Data Binding


<kettic:PerDropDownList ID="PerDropDownList1" runat="server" DropDownHeight="200px" DefaultMessage="Select...">
<WebServiceSettings Method="GetCustomerNames" Path="ClientSideDataBinding.aspx" />
</kettic:PerDropDownList>

Sample C# Codes for Client Side Data Binding


[WebMethod]
public static DropDownListData GetCustomerNames()
{

DataTable data = GetCustomerData();
List<DropDownListItemData> result = new List<DropDownListItemData>();

foreach (DataRow row in data.Rows)
{
DropDownListItemData currentItem = new DropDownListItemData();
currentItem.Text = row["ContactName"].ToString();
currentItem.Value = row["CustomerID"].ToString();
result.Add(currentItem);
}

DropDownListData res = new DropDownListData();
res.Items = result.ToArray();

return res;
}
private static DataTable GetCustomerData()
{
SqlCommand selectCommand = new SqlCommand(@"SELECT * FROM Customers");
return GetData(selectCommand);
}

private static DataTable GetData(SqlCommand selectCommand)
{
selectCommand.Connection = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);

DataTable data = new DataTable();
adapter.Fill(data);

return data;
}

See Also

In addition to the excellent WebServiceSettings client side data binding solution talked about in this page, users still can bind data in server side of KT.UI DropDownList library to all ASP.NET 2.0 DataSource controls, such as SqlDataSource, EntityDataSource, and XmlDataSource.
ASP.NET AJAX UI Controls