Joe Tyman
Joe Tyman

Reputation: 1417

ASP.NET Event not firing

So I have event that basically checks if I have already added to shipment already. I put a break point in at inventoryBLL inv = new inventoryBLL(); and it never breaks. The funny thing is that I can get the index without much fuss.

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

This is the 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>

Upvotes: 0

Views: 676

Answers (2)

Nikola Radosavljević
Nikola Radosavljević

Reputation: 6911

If it's not caused by AutoPostBack of the control being set to false, check if AutoEventWireup is set false. It can be set in several places, including page header and config files.

Upvotes: 1

user596075
user596075

Reputation:

Add AutoPostBack = "true" to your tag. This should be it:

<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.

Upvotes: 4

Related Questions