自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

簡單實現(xiàn)C# ListBox獲取多選項的值

開發(fā) 后端
關于C# ListBox有好多方面要講,今天筆者為大家準備的是如何實現(xiàn)C# ListBox獲取多選項的值。

關于C#  ListBox有好多方面要講,今天筆者為大家準備的是如何實現(xiàn)C# ListBox獲取多選項的值。

  1. protected void Page_Load(object sender, EventArgs e)  
  2.     {  
  3.         if (!IsPostBack)  
  4.         {  
  5.             BindListBox();  
  6.         }  
  7.     }  
  8.     #region 綁定類別名稱到ListBox  
  9.     ///   
  10.     /// 綁定類別名稱到ListBox  
  11.     /// 
  12.  
  13.     void BindListBox()  
  14.     {  
  15.         string sql = "SELECT * FROM ClassTable WHERE PlateID=2 OR PlateID=4";  
  16.         DataTable myClassTable = new ClassTable_bll().WhereToClassTable(sql);  
  17.         ListBox1.DataTextField = "MerchClassName";  
  18.         ListBox1.DataValueField = "ClassID";  
  19.         ListBox1.DataSource = myClassTable.DefaultView;  
  20.         ListBox1.DataBind();  
  21.     }  
  22.     #endregion  
  23.     protected void Button1_Click(object sender, EventArgs e)  
  24.     {  
  25.         string str = "";  
  26.         for (int i = 0; i < ListBox1.Items.Count; i++)  
  27.         {  
  28.             if (ListBox1.Items[i].Selected == true)  
  29.             {  
  30.                 str = str + ListBox1.Items[i].Text+",";                  
  31.             }  
  32.         }  
  33.         this.Response.Write("");  
  34.     }  

以上就是關于C#  ListBox獲取多選項的值的方法介紹。

【編輯推薦】

  1. 解析C# Socket編程實現(xiàn)訪問網(wǎng)絡的原理
  2. C# switch語句簡單描述
  3. C# ServiceController類剖析
  4. C#抓取網(wǎng)頁程序的實現(xiàn)淺析
  5. C#內存管理詳細分析
責任編輯:阡陌 來源: 網(wǎng)絡轉載
相關推薦

2009-09-08 16:22:27

c# listBox

2009-09-11 11:58:00

C# ListBox多

2009-09-08 16:34:49

C# Listbox

2009-09-10 12:00:09

C# listbox

2009-09-08 15:12:07

C# ListBox

2009-08-12 15:50:40

C# ListBox

2009-08-19 11:21:02

C# ListBox控

2009-08-14 14:19:50

Enhanced LiC#構建

2009-09-08 15:39:00

2009-08-20 16:45:03

C#哈希值

2009-09-08 16:10:03

C# ListBox

2009-09-08 17:37:54

C# listbox控

2009-09-07 15:27:04

C# MessageB

2009-08-13 10:15:50

C#讀取Excel

2009-09-08 14:54:40

C# listBox控

2009-09-02 14:33:57

C#類實現(xiàn)接口

2009-08-31 17:53:20

C#實現(xiàn)索引器

2024-07-22 14:34:20

簡單工廠模式C#

2009-09-08 09:31:54

c# CheckBox

2009-09-08 15:50:44

c# listbox
點贊
收藏

51CTO技術棧公眾號