2011-10-27 204 views
0

所以我有一個事件,主要檢查我是否已經添加到出貨。我在inventoryBLL inv = new inventoryBLL();處設置了一個斷點,它從不中斷。有趣的是,我可以毫不費力地獲得索引。ASP.NET事件沒有觸發

我的C#

protected void rblSwitch1_SelectedIndexChanged(object sender, EventArgs e) 
    { 

     inventoryBLL inv = new inventoryBLL(); 
     List<string> asinholder = new List<string>(); 
     List<string> fnskuholder = new List<string>(); 


     int Index = new int(); 
     asinwrapper asin = asinwrapper.GetSessionWrapper(); 
     if (asin != null) 
     { 
      fnskuholder = asin.FNSKU; 
      asinholder = asin.ASIN; 
      Index = asin.Index; 

     } 
     List<shipmentdetail> detail = new List<shipmentdetail>(); 
     multipleshipments m = multipleshipments.GetSessionWrapper(); 
     if (m != null) 
     { 
      detail = m.Detail; 
     } 
     inventory.ItemCheckDataTable items = inv.GetItem(asinholder[Index], detail[0].Id[ddlExisting1.SelectedIndex]); 
     if (items.Rows.Count < 0) 
     { 
      foreach (inventory.ItemCheckRow row in items) 
      { 
       txt.Text = row.Quantity; 
      } 
     } 
    } 

這是HTML

   <asp:RadioButtonList ID="rblSwitch1" runat="server" 
        onselectedindexchanged="rblSwitch1_SelectedIndexChanged"> 
        <asp:ListItem Value="0">New Shipment</asp:ListItem> 
        <asp:ListItem Value="1">Existing Shipment</asp:ListItem> 
       </asp:RadioButtonList> 
+0

是否意味着它在索引存在的語句處打破 –

+0

當你點擊一個listItem時,它不會觸發回發? – Mirthquakes

回答

4

添加AutoPostBack = "true"到您的標籤。這應該是它:

<asp:RadioButtonList ID="rblSwitch1" runat="server" AutoPostBack="true" 
    onselectedindexchanged="rblSwitch1_SelectedIndexChanged"> 
<asp:ListItem Value="0">New Shipment</asp:ListItem> 
<asp:ListItem Value="1">Existing Shipment</asp:ListItem> 
</asp:RadioButtonList> 

Here is a decent reference showing an example.

1

如果它不被控制的AutoPostBack造成被設置爲false,檢查是否AutoEventWireup設置假。它可以在幾個地方設置,包括頁眉和配置文件。