2014-09-25 81 views
0

喜尊重開發人員更給人以標籤警告,如何當用戶檢查比CheckBoxList的規定座位

我試圖發展樣品電影票預訂應用。
我有2 checkboxlists用於選擇座位。
用戶必須選擇座位直到他已經提到的計數,以便從之前的aspx pagedropdownlist中選擇座位。
每當用戶選擇超過所提到的座位時,必須顯示使用標籤的alert,並且必須自動取消選中最新選定的座位。

我被擊中了,我無法前進。當我做錯了,有人幫助我。的

public partial class TestSeat : System.Web.UI.Page 
{ 
    public int count; 
    public static int i =0; 
    protected void Page_Load(object sender, EventArgs e) 
    {  
    } 
    protected void chkboxlist2_click(object sender, EventArgs e) 
    { 
     int conver = Convert.ToInt32(Session["ddlseats"].ToString()); 
     // ddlseats is a dropdownlist selected number of seats by user before entering into this page. 
     if (i >= conver) 
     { 
      chkboxlist2.SelectedItem.Selected = false; 
      Response.Write("Not More than 4 seats can be selected"); 
     } 
     else 
     { 
      if (chkboxlist2.SelectedItem.Selected) 
      { 
      i = i + 1; 
      } 
     } 
    } 
} 

回答

0

代替

if (i >= conver) 
{ 
    ... 

你想

if (value of chkboxlist2 > conver) 
{ 
    Response.Write("Not More than " + conver + " seats can be selected"); 
    etc. 
+0

wazz您好,感謝responding.But我chkboxlist2的值包含seat.How的名稱可以將它用於與比較CONVER? – Swamy 2014-09-25 09:17:52