Hii Tim_Mac
I am trying both options if i am set autopostback=false to third list
then also the selection is changed. when page is get postback. and when
i am set autopostback=true and writting code to selectionchanged for
capturing selected value so third list in this case also value is get
changed.
again i am giving total code to you.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack)
{
try
{
BindDistrictList();
BindSDOList();
BindTalukaList();
BindCircleList();
BindVillageList();
BindSectionDropDownlist();
BindSubSectionDropDownlist();
BindSectionLineDropDownlist();
}
catch(Exception ex)
{
Response.Write("<script language=Javascript>alert('"+
ex.Message.ToString()+"');</script>");
}
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.village_Res_DropDownList.SelectedIndexChanged += new
System.EventHandler(this.village_Res_DropDownList_ SelectedIndexChanged);
this.go_Button.Click += new
System.EventHandler(this.go_Button_Click);
this.section_DropDownList.SelectedIndexChanged += new
System.EventHandler(this.section_DropDownList_Sele ctedIndexChanged);
this.subSection_DropDownList.SelectedIndexChanged += new
System.EventHandler(this.subSection_DropDownList_S electedIndexChanged);
this.sectionLine_DropDownList.SelectedIndexChanged += new
System.EventHandler(this.sectionLine_DropDownList_ SelectedIndexChanged);
this.district_DropDownList.SelectedIndexChanged += new
System.EventHandler(this.district_DropDownList_Sel ectedIndexChanged);
this.SDO_DropDownList.SelectedIndexChanged += new
System.EventHandler(this.SDO_DropDownList_Selected IndexChanged);
this.circle_DropDownList.SelectedIndexChanged += new
System.EventHandler(this.circle_DropDownList_Selec tedIndexChanged);
this.village_DropDownList.SelectedIndexChanged += new
System.EventHandler(this.village_DropDownList_Sele ctedIndexChanged);
this.search_Button.Click += new
System.EventHandler(this.search_Button_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void BindSectionDropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaster.GetSectionRecForReports();
section_DropDownList.DataTextField="SectionDesc";
section_DropDownList.DataValueField ="sectionId";
section_DropDownList.DataSource=dv;
section_DropDownList.DataBind();
section_DropDownList.Items.Insert(0,new
ListItem("--Select--","--Select--"));
}
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--"));
}
private void BindSectionLineDropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaster.GetSectionLineRecReports();
sectionLine_DropDownList.DataTextField="SectionLin eDescription";
sectionLine_DropDownList.DataValueField ="SectionLineId";
sectionLine_DropDownList.DataSource= dv;
sectionLine_DropDownList.DataBind();
sectionLine_DropDownList.Items.Insert(0,new
ListItem("--Select--","-1"));
}
private void section_DropDownList_SelectedIndexChanged(object sender,
System.EventArgs e)
{
try
{
DataSet ds = new DataSet();
ds =
objSectionMaster.GetSubSectionRecForReports1(Conve rt.ToInt32(section_DropDownList.SelectedValue));
subSection_DropDownList.DataTextField="SectionDesc ";
subSection_DropDownList.DataValueField ="SectionId";
subSection_DropDownList.DataSource=ds;
subSection_DropDownList.DataBind();
}
catch(Exception ex)
{
Response.Write("<script language=javascriptalert('"+
ex.Message.ToString()+"');</script>");
}
}
private void subSection_DropDownList_SelectedIndexChanged(objec t
sender, System.EventArgs e)
{
try
{
if(subSection_DropDownList.SelectedValue=="--Select--")
{
return;
}
DataView dv = new DataView();
dv =
objSectionMaster.GetSectionLinesRecForReports(Conv ert.ToInt32(subSection_DropDownList.SelectedValue) );
sectionLine_DropDownList.DataTextField="SectionLin eDescription";
sectionLine_DropDownList.DataValueField ="SectionId";
sectionLine_DropDownList.DataSource=dv;
sectionLine_DropDownList.DataBind();
//resource_Label.Text = sectionLine_DropDownList.SelectedItem.Text;
//sectionLine_DropDownList.Items.Insert(0,new
ListItem("--Select--","--Select--"));
}
catch(Exception ex)
{
Response.Write("<script language=javascriptalert('"+
ex.Message.ToString()+"');</script>");
}
}
Tim_Mac wrote:
hi Santosh,
it is difficult to follow your situation. you say that after you change
List3 that it resets the index back to 0 when the page posts back. am i
right in saying that the postback is because List3 has AutoPostBack=true?
the reason i ask is because you don't appear to have a SelectedIndexChanged
event for List3. so i'm not sure why you would want List3 to post back
itself.
i hope you can clarify the above question. also, please post your aspx code
with the 3 lists, and your InitialiseComponent code to make sure you have
wired the events correctly with the menus.
tim