开发者

add a record to return result in memory

I have some 3 different dropdown list and each dropdown fetch data from database table.

Tables

  1. TableSchool
  2. TableSubject
  3. TableCla开发者_如何学编程ss

As the for load data is fetch using LINQ To SQL. I want to add first row of dropdown to --Select School-- --Select Subject-- --Select Class--

How can that be done?

Code -

 var list = (from i in context.MAT_TableSchool
                    select
                        new
                        {
                            SchoolName= string.Format("SN - {0}", i.SchoolName),
                            SchoolId = i.SchoolId
                        });

this._schoolDropdown.DataSource = list; this._schoolDropdown.DataBind();

What I want is to add a record SchoolName="-Select-" SchoolId=0 at top of this list or dropdown


You don't show a lot of code, so I can only be very generic:

var schoolItems = new string[]{ "--Select School--" }
     .Concat(tableSchoolItems);

Where tableSchoolItems is what you read from the database

** Edit **

var list = new [] { new
            {
                SchoolName = "--Select--",
                SchoolId = 0
            } }.Concat(
    from i in context.MAT_TableSchool 
    select new
            {
                SchoolName= string.Format("SN - {0}", i.SchoolName),
                SchoolId = i.SchoolId
            });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜