本文介绍了Asp.net Dropdownlist选择的索引已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 亲爱的, i正在编写以下代码。 if(Page.IsPostBack == false) { 试试 { BindSectionDropDownlist(); BindSubSectionDropDownlist(); BindSectionLineDropDownlist(); } catch(例外情况) { Response.Write("< script language = Javascript> alert(''" + ex.Message.ToString()+"'');< / script> ;"); } } } // BindSectionDropDownList的定义 private void BindSectionDropDownlist() { DataView dv = new DataView(); dv = objSectionMaster.GetSectionRecForReports(); reportCategory_Dropdownlist.DataTextField =" Section Desc"; reportCategory_Dropdownlist.DataValueField =" sectionId"; reportCategory_Dropdownlist.DataSource = dv; reportCategory_Dropdownli st.DataBind(); reportCategory_Dropdownlist.Items.Insert(0,new ListItem(" - Select - "," - Select-- "); //reportCategoty_DropDownList.SelectedIndex=-1; } private void BindSubSectionDropDownlist() { DataView dv = new DataView(); dv = objSectionMaster.GetSubSectionRecReports(); subSection_Dropdownlist.DataTextField =" SectionDesc"; subSection_Dropdownlist.DataValueField =" sectionId"; subSection_Dropdownlist.DataSource = dv; subSection_Dropdownlist.DataBind( ); subSection_Dropdownlist.Items.Insert(0,new ListItem(" - Select - "," - Select - ")) ; //reportCategoty_DropDownList.SelectedIndex=-1; } private void BindSectionLineDropDownlist() { DataView dv = new DataView(); dv = objSectionMaster.GetSectionLineR ecReports(); sectionLineDesc_DropDownList.DataTextField =" Sectio nLineDescription" ;; sectionLineDesc_DropDownList.DataValueField =" SectionLineId"; sectionLineDesc_DropDownList.DataSource = dv; sectionLineDesc_DropDownList.DataBind(); sectionLineDesc_DropDownList.Items.Insert(0,new ListItem(" - 选择 - "," -1")); //reportCategoty_DropDownList.SelectedIndex=-1; } private void search_Button_Click(object sender,System.EventArgs e) { selectQuery(); } selectQuery(); { //基于 sectionLineDesc_DropDownList选择 } 前两个下拉列表的选择索引没有改变但是 第三个被选中当我点击搜索时,第三个下拉列表的索引被更改 按钮。 任何帮助将不胜感激。 Dear all , i am writting following code. if(Page.IsPostBack==false){try{ BindSectionDropDownlist();BindSubSectionDropDownlist();BindSectionLineDropDownlist();} catch(Exception ex){Response.Write("<script language=Javascript>alert(''"+ex.Message.ToString()+"'');</script>");}}}// Defination of BindSectionDropDownListprivate void BindSectionDropDownlist(){DataView dv = new DataView();dv = objSectionMaster.GetSectionRecForReports();reportCategory_Dropdownlist.DataTextField="Section Desc";reportCategory_Dropdownlist.DataValueField ="sectionId";reportCategory_Dropdownlist.DataSource=dv;reportCategory_Dropdownlist.DataBind();reportCategory_Dropdownlist.Items.Insert(0,newListItem("--Select--","--Select--")); //reportCategoty_DropDownList.SelectedIndex=-1;}private void BindSubSectionDropDownlist(){DataView dv = new DataView();dv = objSectionMaster.GetSubSectionRecReports();subSection_Dropdownlist.DataTextField="SectionDesc ";subSection_Dropdownlist.DataValueField ="sectionId";subSection_Dropdownlist.DataSource=dv;subSection_Dropdownlist.DataBind();subSection_Dropdownlist.Items.Insert(0,newListItem("--Select--","--Select--")); //reportCategoty_DropDownList.SelectedIndex=-1;}private void BindSectionLineDropDownlist(){ DataView dv = new DataView();dv = objSectionMaster.GetSectionLineRecReports();sectionLineDesc_DropDownList.DataTextField="Sectio nLineDescription";sectionLineDesc_DropDownList.DataValueField ="SectionLineId";sectionLineDesc_DropDownList.DataSource= dv;sectionLineDesc_DropDownList.DataBind(); sectionLineDesc_DropDownList.Items.Insert(0,newListItem("--Select--","-1")); //reportCategoty_DropDownList.SelectedIndex=-1;} private void search_Button_Click(object sender, System.EventArgs e){selectQuery();} selectQuery();{ //Code for further processing of on the basis ofsectionLineDesc_DropDownList selection} selection index of first two dropdownlist is not changed butthe third selected index of third dropdownlist is changedwhen i am click on search button.any help will be greatly appreciated. 推荐答案 这篇关于Asp.net Dropdownlist选择的索引已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-25 06:47