开发者

Access to database table structure in a .aspx page

开发者 https://www.devze.com 2023-02-06 19:03 出处:网络
I have a table Software in my database with the开发者_开发问答 following columns: id [key] title

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

精彩评论

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