Home All Groups Group Topic Archive Search About

Asp.net Dropdownlist selected index in changed

Author
4 Sep 2006 10:23 AM
Santosh
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.

Author
6 Sep 2006 9:05 AM
Tim_Mac
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


Show quote
"Santosh" <Santoshmshinde***@yahoo.com> wrote in message
news:1157365428.171679.43920@h48g2000cwc.googlegroups.com...
> 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.
>
Author
7 Sep 2006 11:00 AM
Santosh
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:
Show quote
> 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***@yahoo.com> wrote in message
> news:1157365428.171679.43920@h48g2000cwc.googlegroups.com...
> > 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.
> >
Author
8 Sep 2006 7:51 AM
Tim_Mac
typically this is done via AutoPostBack dropdownlists.  it seems strange
that you bind all 3 lists on the first Page_Load, since you can't know what
to populate lists 2 and 3 with until a selection has been made with list 1.

normally i would do something like this (pseudo-code):
First Page_Load (!PostBack) > Bind List 1    (lists 2 and 3 remain empty)
List1_SelectedIndex_Changed > Bind List 2
List2_SelectedIndex_Changed > Bind List 3
List3_SelectedIndex_Changed > Search whatever

have you got AutoPostBack=true on all the lists?  also, you haven't posted
the SelectedIndexChanged events.  it's very difficult to piece together your
situation with only a part of the code.  if you post all the relevant code i
will be happy to take a look again.

tim


Show quote
"Santosh" <Santoshmshinde***@yahoo.com> wrote in message
news:1157626805.588538.29190@p79g2000cwp.googlegroups.com...
> 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***@yahoo.com> wrote in message
>> news:1157365428.171679.43920@h48g2000cwc.googlegroups.com...
>> > 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.
>> >
>
Author
9 Sep 2006 10:11 AM
Santosh
Here is code ..


private void Page_Load(object sender, System.EventArgs e)
        {
            // Put user code to initialize the page here
                if(!Page.IsPostBack)
            {
                try
                {
                    BindSectionDropDownlist();
                    BindSubSectionDropDownlist();
                    BindSectionLineDropDownlist();
                                    }

                catch(Exception ex)
                {
                    Response.Write("<script language=Javascript>alert('"+
ex.Message.ToString()+"');</script>");
                }
            }
        }


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="SectionLineDescription";
            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(Convert.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=javascript> alert('"+
ex.Message.ToString()+"');</script>");
            }



private void subSection_DropDownList_SelectedIndexChanged(object
sender, System.EventArgs e)
        {
            try
            {
                if(subSection_DropDownList.SelectedValue=="--Select--")
                {
                    return;
                }

                DataView dv = new DataView();
                dv =
objSectionMaster.GetSectionLinesRecForReports(Convert.ToInt32(subSection_DropDownList.SelectedValue));
                sectionLine_DropDownList.DataTextField="SectionLineDescription";
                sectionLine_DropDownList.DataValueField ="SectionId";
                sectionLine_DropDownList.DataSource=dv;
                sectionLine_DropDownList.DataBind();

            }
            catch(Exception ex)
            {
                Response.Write("<script language=javascript> alert('"+
ex.Message.ToString()+"');</script>");
            }
        }


private void search_Button_Click(object sender, System.EventArgs e)
        {
            SearchCondition();
        }


Private void SearchCondition ();
{
   Code for Searching according to the selection of third dropdown
list.
}


Regards

Shinde Santosh.


Tim_Mac wrote:
Show quote
> typically this is done via AutoPostBack dropdownlists.  it seems strange
> that you bind all 3 lists on the first Page_Load, since you can't know what
> to populate lists 2 and 3 with until a selection has been made with list 1.
>
> normally i would do something like this (pseudo-code):
> First Page_Load (!PostBack) > Bind List 1    (lists 2 and 3 remain empty)
> List1_SelectedIndex_Changed > Bind List 2
> List2_SelectedIndex_Changed > Bind List 3
> List3_SelectedIndex_Changed > Search whatever
>
> have you got AutoPostBack=true on all the lists?  also, you haven't posted
> the SelectedIndexChanged events.  it's very difficult to piece together your
> situation with only a part of the code.  if you post all the relevant code i
> will be happy to take a look again.
>
> tim
>
>
> "Santosh" <Santoshmshinde***@yahoo.com> wrote in message
> news:1157626805.588538.29190@p79g2000cwp.googlegroups.com...
> > 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***@yahoo.com> wrote in message
> >> news:1157365428.171679.43920@h48g2000cwc.googlegroups.com...
> >> > 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.
> >> >
> >
Author
11 Sep 2006 11:41 AM
Tim_Mac
hi Santosh,
your code looks normal.  in your original post, you say

"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."

i am assuming that you have EnableViewStated = true and AutoPostBack=true
set on all 3 drop down lists, and that the SelectedIndexChanged events are
correctly registered for all 3 menus, and that these events are firing
correctly.
if this is the case then when you change List1, it will postback and the
selectedIndex of List1 should stay on what you selected.  It should also
stay for all future postbacks unless you re-bind the list.  Does this
happen?

when you click on the search button, the SelectedIndex of all 3 lists should
be the same as you left it.  from the description of your steps below, can
you say exactly where your code behaves unexpectedly:

Step 1: change List1
Step 2: change List2
Step 3: change List3
Step 4: click search.

tim



Show quote
"Santosh" <Santoshmshinde***@yahoo.com> wrote in message
news:1157796681.766632.104180@e3g2000cwe.googlegroups.com...
> Here is code ..
>
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
>            if(!Page.IsPostBack)
> {
> try
> {
> BindSectionDropDownlist();
> BindSubSectionDropDownlist();
> BindSectionLineDropDownlist();
> }
>
> catch(Exception ex)
> {
> Response.Write("<script language=Javascript>alert('"+
> ex.Message.ToString()+"');</script>");
> }
> }
> }
>
>
> 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="SectionLineDescription";
> 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(Convert.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=javascript> alert('"+
> ex.Message.ToString()+"');</script>");
> }
>
>
>
> private void subSection_DropDownList_SelectedIndexChanged(object
> sender, System.EventArgs e)
> {
> try
> {
> if(subSection_DropDownList.SelectedValue=="--Select--")
> {
> return;
> }
>
> DataView dv = new DataView();
> dv =
> objSectionMaster.GetSectionLinesRecForReports(Convert.ToInt32(subSection_DropDownList.SelectedValue));
> sectionLine_DropDownList.DataTextField="SectionLineDescription";
> sectionLine_DropDownList.DataValueField ="SectionId";
> sectionLine_DropDownList.DataSource=dv;
> sectionLine_DropDownList.DataBind();
>
> }
> catch(Exception ex)
> {
> Response.Write("<script language=javascript> alert('"+
> ex.Message.ToString()+"');</script>");
> }
> }
>
>
> private void search_Button_Click(object sender, System.EventArgs e)
> {
> SearchCondition();
> }
>
>
> Private void SearchCondition ();
> {
>   Code for Searching according to the selection of third dropdown
> list.
> }
>
>
> Regards
>
> Shinde Santosh.
>
>
> Tim_Mac wrote:
>> typically this is done via AutoPostBack dropdownlists.  it seems strange
>> that you bind all 3 lists on the first Page_Load, since you can't know
>> what
>> to populate lists 2 and 3 with until a selection has been made with list
>> 1.
>>
>> normally i would do something like this (pseudo-code):
>> First Page_Load (!PostBack) > Bind List 1    (lists 2 and 3 remain empty)
>> List1_SelectedIndex_Changed > Bind List 2
>> List2_SelectedIndex_Changed > Bind List 3
>> List3_SelectedIndex_Changed > Search whatever
>>
>> have you got AutoPostBack=true on all the lists?  also, you haven't
>> posted
>> the SelectedIndexChanged events.  it's very difficult to piece together
>> your
>> situation with only a part of the code.  if you post all the relevant
>> code i
>> will be happy to take a look again.
>>
>> tim
>>
>>
>> "Santosh" <Santoshmshinde***@yahoo.com> wrote in message
>> news:1157626805.588538.29190@p79g2000cwp.googlegroups.com...
>> > 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***@yahoo.com> wrote in message
>> >> news:1157365428.171679.43920@h48g2000cwc.googlegroups.com...
>> >> > 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.
>> >> >
>> >
>

AddThis Social Bookmark Button