2011-10-27 3 views
0

J'ai donc un événement qui vérifie essentiellement si j'ai déjà ajouté à l'expédition déjà. Je mets un point de rupture à inventoryBLL inv = new inventoryBLL(); et il ne casse jamais. La chose amusante est que je peux obtenir l'index sans beaucoup d'histoires.ASP.NET Événement ne se déclenche pas

Mon 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; 
      } 
     } 
    } 

C'est le 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

Voulez-vous dire qu'il casse à l'instruction où l'index est présent –

+0

Il ne déclenche pas une publication lorsque vous cliquez sur une listeIl est-il? – Mirthquakes

Répondre

4

Ajouter AutoPostBack = "true" votre tag. Cela devrait être le:

<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

Si ce n'est pas causée par AutoPostBack du contrôle étant réglé sur faux, vérifier si AutoEventWireup est réglé faux. Il peut être défini à plusieurs endroits, y compris l'en-tête de page et les fichiers de configuration.

Questions connexes