开发者

Access to database table structure in a .aspx page

I have a table Software in my database with the开发者_开发问答 following columns:

id [key]
title
manufacturer

I have a dropdown list in a webform .aspx file. I want the items in the drop down to be Id, title and manufacturer but I dont want to hard-code the items.

I am going to add more columns in the database table and I want the drop down list items to always remain in sync with the table structure.

How do I accomplish this?


If you use LINQ:

var columnNames = dataTable1.Columns.OfType<DataColumn>().
                  Select(c => c.ColumnName).ToList();
comboBox1.DataSource = columnNames;
comboBox1.DataBind();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜