Rahul Systematix
Привет
Попробуйте этот пример
Разметка
<!DOCTYPE html>
<html>
<head>
<title>Populate Data in HTML5 datalist using Asp.Net DataTable</title>
</head>
<body>
<form id="form1" runat="server">
<div style="padding:10px 5px;
border:dashed 1px #CCC;
width:300px;font:15px Arial;">
Select Books <input list="books">
<datalist id="books" runat="server"></datalist>
</div>
</form>
</body>
</html>
Код Позади (C#)using System;
public partial class _Default : System.Web.UI.Page
{
System.Data.DataTable mytable = new System.Data.DataTable();
protected void Page_Load(object sender, EventArgs e)
{
CreateBooksTable();
PopulateDataList();
}
private void CreateBooksTable()
{
System.Data.DataColumn tColumn = null;
// TABLE COLUMNS.
tColumn = new System.Data.DataColumn("Book ID", System.Type.GetType("System.String"));
mytable.Columns.Add(tColumn);
mytable.Rows.Add("Advanced Composite Material");
mytable.Rows.Add("Asp.Net 4 Blue Book");
mytable.Rows.Add("Teaching Science");
mytable.Rows.Add("Circuit Bending");
mytable.Rows.Add("ADOBE Premiere");
}
private void PopulateDataList()
{
for (int i = 0; i <= mytable.Rows.Count - 1; i++)
{
// ADD VALUES TO .
books.InnerHtml = books.InnerHtml + System.Environment.NewLine +
String.Format("<option value='{0}'>", mytable.Rows[i][0]);
}
}
}