DropDownList's SelectedIndexChanged event is not triggered
-
I read several posts online & verified the following: 1. AutoPostBack="true" 2. EnableViewState="True" (default) 3. CausesValidation = "False" (default) Also added the EnableViewState="true" on the page-level directive. Inspite of this I am unable to cause the SelectedIndexChanged event to trigger. I am using VS2010, VB.NET with no AJAX. I am populating my dropdownlist in the PageLoad event and on the condition If (Not IsPostback) Another issue is that my dropdownlist items are getting cleared on postback each time. So as a work around I added SQLDataSource on my aspx page and configured it as datasource to my dropdownlist and now the event is getting triggered properly, I am not sure why. I am new to VB.NET and web development and I feel I am missing something obvious, like taking into consideration Page events chronology, please suggest. Thanks for all your help in advance.
<%@ Page Title="" Language="VB" MasterPageFile="~/MyMaster.master" AutoEventWireup="false" CodeFile="MyPage.aspx.vb" Inherits="MyPage" EnableViewState="true" %>
Title
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration.ConfigurationManagerPartial Class MyPage Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If IsPostBack Then
Exit Sub
End If
PopulateData()
End SubPrivate Sub PopulateData() Dim da As New SqlDataAdapter Dim ds1, ds2, ds3 As New DataSet Try Using
-
I read several posts online & verified the following: 1. AutoPostBack="true" 2. EnableViewState="True" (default) 3. CausesValidation = "False" (default) Also added the EnableViewState="true" on the page-level directive. Inspite of this I am unable to cause the SelectedIndexChanged event to trigger. I am using VS2010, VB.NET with no AJAX. I am populating my dropdownlist in the PageLoad event and on the condition If (Not IsPostback) Another issue is that my dropdownlist items are getting cleared on postback each time. So as a work around I added SQLDataSource on my aspx page and configured it as datasource to my dropdownlist and now the event is getting triggered properly, I am not sure why. I am new to VB.NET and web development and I feel I am missing something obvious, like taking into consideration Page events chronology, please suggest. Thanks for all your help in advance.
<%@ Page Title="" Language="VB" MasterPageFile="~/MyMaster.master" AutoEventWireup="false" CodeFile="MyPage.aspx.vb" Inherits="MyPage" EnableViewState="true" %>
Title
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration.ConfigurationManagerPartial Class MyPage Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If IsPostBack Then
Exit Sub
End If
PopulateData()
End SubPrivate Sub PopulateData() Dim da As New SqlDataAdapter Dim ds1, ds2, ds3 As New DataSet Try Using
You need to bind event "ddl_SelectedIndexChanged" with dropdown list.
Parwej Ahamad
-
You need to bind event "ddl_SelectedIndexChanged" with dropdown list.
Parwej Ahamad
Thanks for the help. But in VB.NET the event handling happens in the code-behind using "Function Handles control.event" kind of signature. You can find that in the code I have posted in my original question.