0

Asp.net dropdownList コントロールがいくつかあります。リスト ドキュメントには DocID 、 UniqueIdentifier 、 Name の 3 つのプロパティがあります。「IF」条件を通過するこのレコードのみでDDLを埋める方法。疑似コードです。

 List<IR_DocumentType> docs = IR_DocumentType.getDocType();
 foreach (IR_DocumentType item in docs)
 {
    if (item.DocID ==1)
    {
    }
 }
 //dropdownList
 DDL.DataSoure = docs;
 DDL.Bind();

\

4

2 に答える 2

0
        List<IR_DocumentType> docs = IR_DocumentType.getDocType();

        foreach (IR_DocumentType item in docs)
        {
            if (item.DocID ==1) // your condition
            {
              DDL.Items.Add(new ListItem(item.Name, item.UniqueIdentifier);
            }
        }
于 2013-08-31T09:01:02.497 に答える
0

以下のコードを参照してください

List<IR_DocumentType> docs = IR_DocumentType.getDocType();
 DDL.DataSoure = new DataTable(); // you can skip this 
 DDL.DataTextField = "Name";  //or "UniqueIdentifier"
 DDL.DataValueField = "DocID" ;
 DDL.Bind();
 foreach (IR_DocumentType item in docs)
  {
 if (item.DocID ==1)
    {
     DDL.Items.Insert(item.DocID, item.Naem );
     //or item.UniqueIdentifier you can also use     
    //a counter instead of item.DocID
                }
            }

これが役立つことを教えてください

于 2013-08-31T07:49:19.947 に答える