我将静态数据添加到商店:
List<object> data = new List<object>() {
new { name="", grouptype="Normal Types", fieldtype="SimpleText", tooltip="", icon="../Images/buttons/01_simpletext.svg", tabular=1 }};
LabDatatoStore();
this.StoreControlTypes.DataSource = data;
this.StoreControlTypes.DataBind();
我正在调用LabDatatoStore()来添加数据库中的一些动态数据:
protected void LabDatatoStore()
{
DAL.DataContext dc = new DAL.DataContext();
var data = from i in dc.Tests
where i.id != "HEIGHT" && i.id != "WEIGHT"
select new { fieldtype = i.id, grouptype = "Data Types", tooltip = i.Name, icon = "../Images/test.png" };
this.StoreControlTypes.DataSource = data;
this.StoreControlTypes.DataBind();
}
但我只得到静态数据。我怎么能得到这两个?
答案 0 :(得分:0)
以下是我解决它的方法:
List<object> data = new List<object>() {
new { name="", grouptype="Normal Types", fieldtype="SimpleText", tooltip="", icon="../Images/buttons/01_simpletext.svg" },
new { name="", grouptype="Normal Types", fieldtype="LongText", tooltip="", icon="../Images/buttons/02_textlong.svg" },
new { name="", grouptype="Normal Types", fieldtype="Numeric", tooltip="", icon="../Images/buttons/03_numeric.svg" }
};
DAL.DataContext dc = new DAL.DataContext();
var dataDyn = from i in dc.Tests
where i.id != "HEIGHT" && i.id != "WEIGHT"
select new { fieldtype = i.id, grouptype = "Data Types", tooltip = i.Name, icon = "../Images/test.png" };
data.AddRange(dataDyn.ToArray());
this.StoreControlTypes.DataSource = data;
this.StoreControlTypes.DataBind();