|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dropdownlist..urgent helpgetting fired. Please help. Thanks, Here is the code: public class class1: Systems.Web.UI.Page { //all the declarations public void GetItems() { // GetConnection is a function that gets connection string and opens the //connection SqlConnection myConn = GetConnection(); DataSet dsTemp; dsTemp = new DataSet(); string strSQl ="Select name from Company"; SqlDataAdapter myAda = new SQlAdapter(strSQL,myConn); myAda.Fill(dsTemp,"temptab"); DDLName.DataSource = dsTemp.Tables["temptab"]; DDLName.DataTextField = dsTemp.Tables["temptab"].Columns[0].ToString(); DDLName.DataValueField = dsTemp.Tables["temptab"].Columns[0].ToString(); DDLName.DataBind(); myConn.Close(); } public void DDLName_SelectedIndexChanged(object sernder,EventArgs e) { lblLabel2.Text = "Event Fired" + DDLName.SelectItem.Text; /// Do some things here like set another DDL List according to selectedItem } private void Page_Load(object sender,EventArgs e) { DDLName.AutoPostBack = true; DDLName.EnableViewState = false; if(!Postback) { GetItems(); } } protected override void OnInit(EventArgs e) { DDLName.SelectedIndexChanged += new EventHandler(DDLName_SelectedIndexChanged); } } Hi Isabel,
It happens sometimes even though you had declared the delegate event of the control's SelectedIndexChanged it doesn't fire at runtime.Try these options 1.Create a new webpage,test this control on that web page 2.Or use the click event of the control in the same page (instead of the the new web page, option 1.) Raj Show quote "Isabel" <Isa***@discussions.microsoft.com> wrote in message news:F3DC990F-401B-4B79-9942-E644A0E38DBB@microsoft.com... > I have a dropdownlist ,for which i think the selectindexchnaged event is not > getting fired. Please help. > Thanks, > > Here is the code: > > public class class1: Systems.Web.UI.Page > { > //all the declarations > public void GetItems() > { > // GetConnection is a function that gets connection string and opens > the > //connection > SqlConnection myConn = GetConnection(); > DataSet dsTemp; > dsTemp = new DataSet(); > string strSQl ="Select name from Company"; > SqlDataAdapter myAda = new SQlAdapter(strSQL,myConn); > myAda.Fill(dsTemp,"temptab"); > DDLName.DataSource = dsTemp.Tables["temptab"]; > DDLName.DataTextField = dsTemp.Tables["temptab"].Columns[0].ToString(); > DDLName.DataValueField = dsTemp.Tables["temptab"].Columns[0].ToString(); > DDLName.DataBind(); > myConn.Close(); > } > public void DDLName_SelectedIndexChanged(object sernder,EventArgs e) > { > lblLabel2.Text = "Event Fired" + DDLName.SelectItem.Text; > /// Do some things here like set another DDL List according to > selectedItem > } > private void Page_Load(object sender,EventArgs e) > { > DDLName.AutoPostBack = true; > DDLName.EnableViewState = false; > if(!Postback) > { > GetItems(); > } > } > protected override void OnInit(EventArgs e) > { > DDLName.SelectedIndexChanged += new > EventHandler(DDLName_SelectedIndexChanged); > } > } |
|||||||||||||||||||||||