English 中文(简体)
com博箱填充 as本。
原标题:combo-box fill in asp.net
var metroquery = (from metro in objCommon.Lst_Cities
where (SqlMethods.Like(metro.CityNM, "Mumbai") ||
SqlMethods.Like(metro.CityNM, "Delhi" )||
SqlMethods.Like(metro.CityNM, "Kolkata") ||
SqlMethods.Like(metro.CityNM, "Chennai") || 
SqlMethods.Like(metro.CityNM, "Bangalore") ||
SqlMethods.Like(metro.CityNM, "Pune") ||
SqlMethods.Like(metro.CityNM ,"Ahmedabad") ||
SqlMethods.Like(metro.CityNM , "Hyderbad"))
select metro).ToList();

     var nonmetroquery = (from metro in objCommon.Lst_Cities
     where !metro.CityNM.Contains("Mumbai") &&
     !metro.CityNM.Contains("Delhi") &&
     !metro.CityNM.Contains("Kolkata") &&
     !metro.CityNM.Contains("Chennai") &&
  !metro.CityNM.Contains("Bangalore") &&
    !metro.CityNM.Contains("Pune") &&
    !metro.CityNM.Contains("Ahmedabad") &&
    !metro.CityNM.Contains("Hyderbad")
    select metro).ToList();

我写了这两份林克问询,以检索城市,并补充城市的第一线,即孟买和其他顶端城市。 第二点是,我只想向 com子看望的非流城市。

基本上,我想要在最上城市和非下游城市的城市举行有会议。

我为此使用了以下法典:

 List<Lst_City> lstCity1 = new List<Lst_City>();


            foreach (var t in metroquery)
            {

                lstCity1 = metroquery;

            }

            System.Threading.Thread.Sleep(200);

            foreach (var t in nonmetroquery)
            {
                lstCity1 = nonmetroquery;
            }

but I am getting only the non metro cities binded to the ComboBox.

任何帮助?

最佳回答

在您的每种方法中,你正在增加整个清单,而不是<代码>var t。

或许这项工作将:

List<Lst_City> lstCity1 = new List<Lst_City>();

            foreach (var t in metroquery)
            {

                lstCity1.Add(t);

            }

            System.Threading.Thread.Sleep(200);

            foreach (var t in nonmetroquery)
            {
                lstCity1.Add(t);
            }
问题回答

您将非按顺序排列(第二代为每一方)的结果列入您的名单,取代名单的前内容。

你应该这样做:

lstCity1.AddRange(metroquery);
lstCity1.AddRange(nonmetroquery); 

你们可以利用“文化”级过滤器,利用所有工会来实现这一目标。

请参看以下链接。

http://dotnetalliance.blogspot.in/2008/02/how-to-select-major-cities-on-top-in-sql.html





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签