Re: Asp.net Dropdownlist selected index in changed



The description is ,

i am having three dropdownlists when i am selected first item from list
it will display all related items in the next drop down list when i am
choose item from second drop down list in third all items filled
related to second item selection. and in the selection of third
dropdown list item text i will be display result.

eg.i am having first dropdownlist it will contains all country list
when i am choose one country it will display all states related to that
country. if i am selected state from list it will display all districts
related to the selected states. and on the selection of district i will
be search another information.

Tim_Mac wrote:
hi,
first it would be useful to describe what you are trying to do. code is
helpful but it's no good unless you describe what you are trying to do with
it!

you say that the selected index of the first two dropdownlists are not
changed, are they supposed to change? in response to the user? or your
code?
you have this line of code in each bind method:
//reportCategoty_DropDownList.SelectedIndex=-1;
is it supposed to be uncommented?

happy to help if you can provide more info
tim


"Santosh" <Santoshmshinde_it@xxxxxxxxx> wrote in message
news:1157365428.171679.43920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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 BindSectionDropDownList


private void BindSectionDropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaster.GetSectionRecForReports();
reportCategory_Dropdownlist.DataTextField="SectionDesc";
reportCategory_Dropdownlist.DataValueField ="sectionId";
reportCategory_Dropdownlist.DataSource=dv;
reportCategory_Dropdownlist.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.GetSectionLineRecReports();
sectionLineDesc_DropDownList.DataTextField="SectionLineDescription";
sectionLineDesc_DropDownList.DataValueField ="SectionLineId";
sectionLineDesc_DropDownList.DataSource= dv;
sectionLineDesc_DropDownList.DataBind();

sectionLineDesc_DropDownList.Items.Insert(0,new
ListItem("--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 of
sectionLineDesc_DropDownList selection


}

selection index of first two dropdownlist is not changed but
the third selected index of third dropdownlist is changed
when i am click on search button.


any help will be greatly appreciated.


.