[英]Asp.net OnSelectedIndexChanged event not firing despite autopostback being true
[英]ASP.NET onselectedindexchanged event not firing when using loadcontrol
在普通的vb類中,我使用下拉列表加載usercontrol
Dim products As UserControl = Page.LoadControl("~/Controls/Products.ascx")
products.ID = "Products"
tile.Controls.Add(products)
但是由於某種原因,我的onindexchanged事件(在usercontrol中)沒有觸發。
碼:
Partial Class Controls_Products
Inherits System.Web.UI.UserControl
Public Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim myPage As BasePage = CType(Me.Page, BasePage)
Dim dsProducts As DataSet = eyeCatalogueFunctions.GetProduct(0, myPage.GetLang, myPage.GetCustid, 0, "", 0, Nothing, 0)
If Not IsNothing(dsProducts) AndAlso dsProducts.Tables.Count > 0 AndAlso dsProducts.Tables(0).Rows.Count > 0 Then
With Me.ddlProducts
.DataSource = dsProducts.Tables(0)
.DataTextField = "product_nam"
.DataValueField = "seqproduct"
.DataBind()
End With
Me.lblTest.Text = Me.ddlProducts.Items(0).Text
End If
End If
End Sub
Protected Sub ddlProducts_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlProducts.SelectedIndexChanged
'Do something
End Sub
用戶控件中沒有什么特別的:
<%@ Control Language="VB" AutoEventWireup="true" CodeFile="Products.ascx.vb" Inherits="Controls_Products" EnableViewState="true" %>
有任何想法嗎 ?
將產品控件的“檢查AutoPostBack”屬性設置為true 。
可能您可以將其設置為產品。AutoPostBack= true
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.