Hi,
check the following example. Hope it helps.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Web.Services" %>
<script runat="server">
[WebMethod]
public DataTable GetDummyDataTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("ID", typeof(int)));
dt.Columns.Add(new DataColumn("Name", typeof(String)));
dt.Columns.Add(new DataColumn("LastName", typeof(String)));
dt.Rows.Add(1, "John", "Doe");
dt.Rows.Add(2, "John", "Smith");
return dt;
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ListBox Databinding Example</title>
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="sm" runat="server" />
<div>
<select id="myListBox"></select>
</div>
<div>
<span>Selected Value is </span>
<span id="myLabel"></span>
</div>
</form>
<script type="text/javascript">
function populateList() {
PageMethods.GetDummyDataTable(onGetComplete);
}
function onGetComplete(result) {
var myListBox = Sys.Application.findObject('myListBox');
myListBox.set_data(result);
}
</script>
<script type="text/xml-script">
<page>
<components>
<select id="myListBox"
textProperty="LastName"
valueProperty="ID"
firstItemText="Make Your Selection"
/>
<label id="myLabel">
<bindings>
<binding dataContext="myListBox"
dataPath="selectedValue"
property="text"
/>
</bindings>
</label>
<application load="populateList" />
</components>
</page>
</script>
</body>
</html>