473,740 Members | 9,506 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asp.net Dropdownlist selected index in changed

Dear all ,

i am writting following code.

if(Page.IsPostB ack==false)
{
try
{

BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
// Defination of BindSectionDrop DownList
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();
reportCategory_ Dropdownlist.Da taTextField="Se ctionDesc";
reportCategory_ Dropdownlist.Da taValueField ="sectionId" ;
reportCategory_ Dropdownlist.Da taSource=dv;
reportCategory_ Dropdownlist.Da taBind();
reportCategory_ Dropdownlist.It ems.Insert(0,ne w
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop downlist.DataTe xtField="Sectio nDesc";
subSection_Drop downlist.DataVa lueField ="sectionId" ;
subSection_Drop downlist.DataSo urce=dv;
subSection_Drop downlist.DataBi nd();
subSection_Drop downlist.Items. Insert(0,new
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLineDesc _DropDownList.D ataTextField="S ectionLineDescr iption";
sectionLineDesc _DropDownList.D ataValueField ="SectionLineId ";
sectionLineDesc _DropDownList.D ataSource= dv;
sectionLineDesc _DropDownList.D ataBind();

sectionLineDesc _DropDownList.I tems.Insert(0,n ew
ListItem("--Select--","-1"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}

private void search_Button_C lick(object sender, System.EventArg s 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.

Sep 4 '06 #1
11 5811
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.Se lectedIndex=-1;
is it supposed to be uncommented?

happy to help if you can provide more info
tim
"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Dear all ,

i am writting following code.

if(Page.IsPostB ack==false)
{
try
{

BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
// Defination of BindSectionDrop DownList
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();
reportCategory_ Dropdownlist.Da taTextField="Se ctionDesc";
reportCategory_ Dropdownlist.Da taValueField ="sectionId" ;
reportCategory_ Dropdownlist.Da taSource=dv;
reportCategory_ Dropdownlist.Da taBind();
reportCategory_ Dropdownlist.It ems.Insert(0,ne w
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop downlist.DataTe xtField="Sectio nDesc";
subSection_Drop downlist.DataVa lueField ="sectionId" ;
subSection_Drop downlist.DataSo urce=dv;
subSection_Drop downlist.DataBi nd();
subSection_Drop downlist.Items. Insert(0,new
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLineDesc _DropDownList.D ataTextField="S ectionLineDescr iption";
sectionLineDesc _DropDownList.D ataValueField ="SectionLineId ";
sectionLineDesc _DropDownList.D ataSource= dv;
sectionLineDesc _DropDownList.D ataBind();

sectionLineDesc _DropDownList.I tems.Insert(0,n ew
ListItem("--Select--","-1"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}

private void search_Button_C lick(object sender, System.EventArg s 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.

Sep 6 '06 #2
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.Se lectedIndex=-1;
is it supposed to be uncommented?

happy to help if you can provide more info
tim
"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Dear all ,

i am writting following code.

if(Page.IsPostB ack==false)
{
try
{

BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
// Defination of BindSectionDrop DownList
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();
reportCategory_ Dropdownlist.Da taTextField="Se ctionDesc";
reportCategory_ Dropdownlist.Da taValueField ="sectionId" ;
reportCategory_ Dropdownlist.Da taSource=dv;
reportCategory_ Dropdownlist.Da taBind();
reportCategory_ Dropdownlist.It ems.Insert(0,ne w
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop downlist.DataTe xtField="Sectio nDesc";
subSection_Drop downlist.DataVa lueField ="sectionId" ;
subSection_Drop downlist.DataSo urce=dv;
subSection_Drop downlist.DataBi nd();
subSection_Drop downlist.Items. Insert(0,new
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLineDesc _DropDownList.D ataTextField="S ectionLineDescr iption";
sectionLineDesc _DropDownList.D ataValueField ="SectionLineId ";
sectionLineDesc _DropDownList.D ataSource= dv;
sectionLineDesc _DropDownList.D ataBind();

sectionLineDesc _DropDownList.I tems.Insert(0,n ew
ListItem("--Select--","-1"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}

private void search_Button_C lick(object sender, System.EventArg s 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.
Sep 7 '06 #3
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_SelectedI ndex_Changed Bind List 2
List2_SelectedI ndex_Changed Bind List 3
List3_SelectedI ndex_Changed Search whatever

have you got AutoPostBack=tr ue on all the lists? also, you haven't posted
the SelectedIndexCh anged 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" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@p 79g2000cwp.goog legroups.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.Se lectedIndex=-1;
is it supposed to be uncommented?

happy to help if you can provide more info
tim
"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******* **************@ h48g2000cwc.goo glegroups.com.. .
Dear all ,

i am writting following code.

if(Page.IsPostB ack==false)
{
try
{

BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
// Defination of BindSectionDrop DownList
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();
reportCategory_ Dropdownlist.Da taTextField="Se ctionDesc";
reportCategory_ Dropdownlist.Da taValueField ="sectionId" ;
reportCategory_ Dropdownlist.Da taSource=dv;
reportCategory_ Dropdownlist.Da taBind();
reportCategory_ Dropdownlist.It ems.Insert(0,ne w
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop downlist.DataTe xtField="Sectio nDesc";
subSection_Drop downlist.DataVa lueField ="sectionId" ;
subSection_Drop downlist.DataSo urce=dv;
subSection_Drop downlist.DataBi nd();
subSection_Drop downlist.Items. Insert(0,new
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLineDesc _DropDownList.D ataTextField="S ectionLineDescr iption";
sectionLineDesc _DropDownList.D ataValueField ="SectionLineId ";
sectionLineDesc _DropDownList.D ataSource= dv;
sectionLineDesc _DropDownList.D ataBind();

sectionLineDesc _DropDownList.I tems.Insert(0,n ew
ListItem("--Select--","-1"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}

private void search_Button_C lick(object sender, System.EventArg s 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.

Sep 8 '06 #4
Here is code ..
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(!Page.IsPost Back)
{
try
{
BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();

section_DropDow nList.DataTextF ield="SectionDe sc";
section_DropDow nList.DataValue Field ="sectionId" ;
section_DropDow nList.DataSourc e=dv;
section_DropDow nList.DataBind( );
section_DropDow nList.Items.Ins ert(0,new
ListItem("--Select--","--Select--"));

}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop DownList.DataTe xtField="Sectio nDesc";
subSection_Drop DownList.DataVa lueField ="sectionId" ;
subSection_Drop DownList.DataSo urce=dv;
subSection_Drop DownList.DataBi nd();
subSection_Drop DownList.Items. Insert(0,new
ListItem("--Select--","--Select--"));

}

private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLine_Dro pDownList.DataT extField="Secti onLineDescripti on";
sectionLine_Dro pDownList.DataV alueField ="SectionLineId ";
sectionLine_Dro pDownList.DataS ource= dv;
sectionLine_Dro pDownList.DataB ind();

sectionLine_Dro pDownList.Items .Insert(0,new
ListItem("--Select--","-1"));
}

private void section_DropDow nList_SelectedI ndexChanged(obj ect sender,
System.EventArg s e)
{
try
{
DataSet ds = new DataSet();
ds =
objSectionMaste r.GetSubSection RecForReports1( Convert.ToInt32 (section_DropDo wnList.Selected Value));
subSection_Drop DownList.DataTe xtField="Sectio nDesc";
subSection_Drop DownList.DataVa lueField ="SectionId" ;
subSection_Drop DownList.DataSo urce=ds;
subSection_Drop DownList.DataBi nd();
}
catch(Exception ex)
{
Response.Write( "<script language=javasc riptalert('"+
ex.Message.ToSt ring()+"');</script>");
}

private void subSection_Drop DownList_Select edIndexChanged( object
sender, System.EventArg s e)
{
try
{
if(subSection_D ropDownList.Sel ectedValue=="--Select--")
{
return;
}

DataView dv = new DataView();
dv =
objSectionMaste r.GetSectionLin esRecForReports (Convert.ToInt3 2(subSection_Dr opDownList.Sele ctedValue));
sectionLine_Dro pDownList.DataT extField="Secti onLineDescripti on";
sectionLine_Dro pDownList.DataV alueField ="SectionId" ;
sectionLine_Dro pDownList.DataS ource=dv;
sectionLine_Dro pDownList.DataB ind();

}
catch(Exception ex)
{
Response.Write( "<script language=javasc riptalert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
private void search_Button_C lick(object sender, System.EventArg s 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_SelectedI ndex_Changed Bind List 2
List2_SelectedI ndex_Changed Bind List 3
List3_SelectedI ndex_Changed Search whatever

have you got AutoPostBack=tr ue on all the lists? also, you haven't posted
the SelectedIndexCh anged 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" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@p 79g2000cwp.goog legroups.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.Se lectedIndex=-1;
is it supposed to be uncommented?

happy to help if you can provide more info
tim
"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Dear all ,

i am writting following code.

if(Page.IsPostB ack==false)
{
try
{

BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
// Defination of BindSectionDrop DownList
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();
reportCategory_ Dropdownlist.Da taTextField="Se ctionDesc";
reportCategory_ Dropdownlist.Da taValueField ="sectionId" ;
reportCategory_ Dropdownlist.Da taSource=dv;
reportCategory_ Dropdownlist.Da taBind();
reportCategory_ Dropdownlist.It ems.Insert(0,ne w
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop downlist.DataTe xtField="Sectio nDesc";
subSection_Drop downlist.DataVa lueField ="sectionId" ;
subSection_Drop downlist.DataSo urce=dv;
subSection_Drop downlist.DataBi nd();
subSection_Drop downlist.Items. Insert(0,new
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLineDesc _DropDownList.D ataTextField="S ectionLineDescr iption";
sectionLineDesc _DropDownList.D ataValueField ="SectionLineId ";
sectionLineDesc _DropDownList.D ataSource= dv;
sectionLineDesc _DropDownList.D ataBind();

sectionLineDesc _DropDownList.I tems.Insert(0,n ew
ListItem("--Select--","-1"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}

private void search_Button_C lick(object sender, System.EventArg s 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.
Sep 9 '06 #5
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 EnableViewState d = true and AutoPostBack=tr ue
set on all 3 drop down lists, and that the SelectedIndexCh anged 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

"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******** **************@ e3g2000cwe.goog legroups.com...
Here is code ..
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(!Page.IsPost Back)
{
try
{
BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();

section_DropDow nList.DataTextF ield="SectionDe sc";
section_DropDow nList.DataValue Field ="sectionId" ;
section_DropDow nList.DataSourc e=dv;
section_DropDow nList.DataBind( );
section_DropDow nList.Items.Ins ert(0,new
ListItem("--Select--","--Select--"));

}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop DownList.DataTe xtField="Sectio nDesc";
subSection_Drop DownList.DataVa lueField ="sectionId" ;
subSection_Drop DownList.DataSo urce=dv;
subSection_Drop DownList.DataBi nd();
subSection_Drop DownList.Items. Insert(0,new
ListItem("--Select--","--Select--"));

}

private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLine_Dro pDownList.DataT extField="Secti onLineDescripti on";
sectionLine_Dro pDownList.DataV alueField ="SectionLineId ";
sectionLine_Dro pDownList.DataS ource= dv;
sectionLine_Dro pDownList.DataB ind();

sectionLine_Dro pDownList.Items .Insert(0,new
ListItem("--Select--","-1"));
}

private void section_DropDow nList_SelectedI ndexChanged(obj ect sender,
System.EventArg s e)
{
try
{
DataSet ds = new DataSet();
ds =
objSectionMaste r.GetSubSection RecForReports1( Convert.ToInt32 (section_DropDo wnList.Selected Value));
subSection_Drop DownList.DataTe xtField="Sectio nDesc";
subSection_Drop DownList.DataVa lueField ="SectionId" ;
subSection_Drop DownList.DataSo urce=ds;
subSection_Drop DownList.DataBi nd();
}
catch(Exception ex)
{
Response.Write( "<script language=javasc riptalert('"+
ex.Message.ToSt ring()+"');</script>");
}

private void subSection_Drop DownList_Select edIndexChanged( object
sender, System.EventArg s e)
{
try
{
if(subSection_D ropDownList.Sel ectedValue=="--Select--")
{
return;
}

DataView dv = new DataView();
dv =
objSectionMaste r.GetSectionLin esRecForReports (Convert.ToInt3 2(subSection_Dr opDownList.Sele ctedValue));
sectionLine_Dro pDownList.DataT extField="Secti onLineDescripti on";
sectionLine_Dro pDownList.DataV alueField ="SectionId" ;
sectionLine_Dro pDownList.DataS ource=dv;
sectionLine_Dro pDownList.DataB ind();

}
catch(Exception ex)
{
Response.Write( "<script language=javasc riptalert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
private void search_Button_C lick(object sender, System.EventArg s 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_Selected Index_Changed Bind List 2
List2_Selected Index_Changed Bind List 3
List3_Selected Index_Changed Search whatever

have you got AutoPostBack=tr ue on all the lists? also, you haven't
posted
the SelectedIndexCh anged 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" <Sa************ ***@yahoo.comwr ote in message
news:11******* **************@ p79g2000cwp.goo glegroups.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.Se lectedIndex=-1;
is it supposed to be uncommented?

happy to help if you can provide more info
tim
"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******* **************@ h48g2000cwc.goo glegroups.com.. .
Dear all ,

i am writting following code.

if(Page.IsPostB ack==false)
{
try
{

BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
// Defination of BindSectionDrop DownList
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();
reportCategory_ Dropdownlist.Da taTextField="Se ctionDesc";
reportCategory_ Dropdownlist.Da taValueField ="sectionId" ;
reportCategory_ Dropdownlist.Da taSource=dv;
reportCategory_ Dropdownlist.Da taBind();
reportCategory_ Dropdownlist.It ems.Insert(0,ne w
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop downlist.DataTe xtField="Sectio nDesc";
subSection_Drop downlist.DataVa lueField ="sectionId" ;
subSection_Drop downlist.DataSo urce=dv;
subSection_Drop downlist.DataBi nd();
subSection_Drop downlist.Items. Insert(0,new
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLineDesc _DropDownList.D ataTextField="S ectionLineDescr iption";
sectionLineDesc _DropDownList.D ataValueField ="SectionLineId ";
sectionLineDesc _DropDownList.D ataSource= dv;
sectionLineDesc _DropDownList.D ataBind();

sectionLineDesc _DropDownList.I tems.Insert(0,n ew
ListItem("--Select--","-1"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}

private void search_Button_C lick(object sender, System.EventArg s 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.


Sep 11 '06 #6
Dear Tim

The selected index of first two lists remain same but only thirds are
change it change on
change List3 and and click search also.

please help me. what exactely wrong happen.
regards
Santosh

Tim_Mac wrote:
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 EnableViewState d = true and AutoPostBack=tr ue
set on all 3 drop down lists, and that the SelectedIndexCh anged 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

"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******** **************@ e3g2000cwe.goog legroups.com...
Here is code ..
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(!Page.IsPost Back)
{
try
{
BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();

section_DropDow nList.DataTextF ield="SectionDe sc";
section_DropDow nList.DataValue Field ="sectionId" ;
section_DropDow nList.DataSourc e=dv;
section_DropDow nList.DataBind( );
section_DropDow nList.Items.Ins ert(0,new
ListItem("--Select--","--Select--"));

}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop DownList.DataTe xtField="Sectio nDesc";
subSection_Drop DownList.DataVa lueField ="sectionId" ;
subSection_Drop DownList.DataSo urce=dv;
subSection_Drop DownList.DataBi nd();
subSection_Drop DownList.Items. Insert(0,new
ListItem("--Select--","--Select--"));

}

private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLine_Dro pDownList.DataT extField="Secti onLineDescripti on";
sectionLine_Dro pDownList.DataV alueField ="SectionLineId ";
sectionLine_Dro pDownList.DataS ource= dv;
sectionLine_Dro pDownList.DataB ind();

sectionLine_Dro pDownList.Items .Insert(0,new
ListItem("--Select--","-1"));
}

private void section_DropDow nList_SelectedI ndexChanged(obj ect sender,
System.EventArg s e)
{
try
{
DataSet ds = new DataSet();
ds =
objSectionMaste r.GetSubSection RecForReports1( Convert.ToInt32 (section_DropDo wnList.Selected Value));
subSection_Drop DownList.DataTe xtField="Sectio nDesc";
subSection_Drop DownList.DataVa lueField ="SectionId" ;
subSection_Drop DownList.DataSo urce=ds;
subSection_Drop DownList.DataBi nd();
}
catch(Exception ex)
{
Response.Write( "<script language=javasc riptalert('"+
ex.Message.ToSt ring()+"');</script>");
}

private void subSection_Drop DownList_Select edIndexChanged( object
sender, System.EventArg s e)
{
try
{
if(subSection_D ropDownList.Sel ectedValue=="--Select--")
{
return;
}

DataView dv = new DataView();
dv =
objSectionMaste r.GetSectionLin esRecForReports (Convert.ToInt3 2(subSection_Dr opDownList.Sele ctedValue));
sectionLine_Dro pDownList.DataT extField="Secti onLineDescripti on";
sectionLine_Dro pDownList.DataV alueField ="SectionId" ;
sectionLine_Dro pDownList.DataS ource=dv;
sectionLine_Dro pDownList.DataB ind();

}
catch(Exception ex)
{
Response.Write( "<script language=javasc riptalert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
private void search_Button_C lick(object sender, System.EventArg s 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_SelectedI ndex_Changed Bind List 2
List2_SelectedI ndex_Changed Bind List 3
List3_SelectedI ndex_Changed Search whatever

have you got AutoPostBack=tr ue on all the lists? also, you haven't
posted
the SelectedIndexCh anged 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" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@p 79g2000cwp.goog legroups.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.Se lectedIndex=-1;
is it supposed to be uncommented?

happy to help if you can provide more info
tim
"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Dear all ,

i am writting following code.

if(Page.IsPostB ack==false)
{
try
{

BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
// Defination of BindSectionDrop DownList
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();
reportCategory_ Dropdownlist.Da taTextField="Se ctionDesc";
reportCategory_ Dropdownlist.Da taValueField ="sectionId" ;
reportCategory_ Dropdownlist.Da taSource=dv;
reportCategory_ Dropdownlist.Da taBind();
reportCategory_ Dropdownlist.It ems.Insert(0,ne w
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop downlist.DataTe xtField="Sectio nDesc";
subSection_Drop downlist.DataVa lueField ="sectionId" ;
subSection_Drop downlist.DataSo urce=dv;
subSection_Drop downlist.DataBi nd();
subSection_Drop downlist.Items. Insert(0,new
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLineDesc _DropDownList.D ataTextField="S ectionLineDescr iption";
sectionLineDesc _DropDownList.D ataValueField ="SectionLineId ";
sectionLineDesc _DropDownList.D ataSource= dv;
sectionLineDesc _DropDownList.D ataBind();

sectionLineDesc _DropDownList.I tems.Insert(0,n ew
ListItem("--Select--","-1"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}

private void search_Button_C lick(object sender, System.EventArg s 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.
Sep 11 '06 #7
hi Santosh,
when you say the index remains the same, do you mean when you change the
index to the 5th item (for example) that it stays on the 5th item after the
SelectedIndexCh anged event? or that it stays on the first 'Select...' item
after the event?

tim
"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@i 3g2000cwc.googl egroups.com...
Dear Tim

The selected index of first two lists remain same but only thirds are
change it change on
change List3 and and click search also.

please help me. what exactely wrong happen.
regards
Santosh

Tim_Mac wrote:
>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 EnableViewState d = true and AutoPostBack=tr ue
set on all 3 drop down lists, and that the SelectedIndexCh anged 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
selectedInde x 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

"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******* *************** @e3g2000cwe.goo glegroups.com.. .
Here is code ..
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(!Page.IsPost Back)
{
try
{
BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();

section_DropDow nList.DataTextF ield="SectionDe sc";
section_DropDow nList.DataValue Field ="sectionId" ;
section_DropDow nList.DataSourc e=dv;
section_DropDow nList.DataBind( );
section_DropDow nList.Items.Ins ert(0,new
ListItem("--Select--","--Select--"));

}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop DownList.DataTe xtField="Sectio nDesc";
subSection_Drop DownList.DataVa lueField ="sectionId" ;
subSection_Drop DownList.DataSo urce=dv;
subSection_Drop DownList.DataBi nd();
subSection_Drop DownList.Items. Insert(0,new
ListItem("--Select--","--Select--"));

}

private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLine_Dro pDownList.DataT extField="Secti onLineDescripti on";
sectionLine_Dro pDownList.DataV alueField ="SectionLineId ";
sectionLine_Dro pDownList.DataS ource= dv;
sectionLine_Dro pDownList.DataB ind();

sectionLine_Dro pDownList.Items .Insert(0,new
ListItem("--Select--","-1"));
}

private void section_DropDow nList_SelectedI ndexChanged(obj ect sender,
System.EventArg s e)
{
try
{
DataSet ds = new DataSet();
ds =
objSectionMaste r.GetSubSection RecForReports1( Convert.ToInt32 (section_DropDo wnList.Selected Value));
subSection_Drop DownList.DataTe xtField="Sectio nDesc";
subSection_Drop DownList.DataVa lueField ="SectionId" ;
subSection_Drop DownList.DataSo urce=ds;
subSection_Drop DownList.DataBi nd();
}
catch(Exception ex)
{
Response.Write( "<script language=javasc riptalert('"+
ex.Message.ToSt ring()+"');</script>");
}

private void subSection_Drop DownList_Select edIndexChanged( object
sender, System.EventArg s e)
{
try
{
if(subSection_D ropDownList.Sel ectedValue=="--Select--")
{
return;
}

DataView dv = new DataView();
dv =
objSectionMaste r.GetSectionLin esRecForReports (Convert.ToInt3 2(subSection_Dr opDownList.Sele ctedValue));
sectionLine_Dro pDownList.DataT extField="Secti onLineDescripti on";
sectionLine_Dro pDownList.DataV alueField ="SectionId" ;
sectionLine_Dro pDownList.DataS ource=dv;
sectionLine_Dro pDownList.DataB ind();

}
catch(Exception ex)
{
Response.Write( "<script language=javasc riptalert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
private void search_Button_C lick(object sender, System.EventArg s 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_Selected Index_Changed Bind List 2
List2_Selected Index_Changed Bind List 3
List3_Selected Index_Changed Search whatever

have you got AutoPostBack=tr ue on all the lists? also, you haven't
posted
the SelectedIndexCh anged 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" <Sa************ ***@yahoo.comwr ote in message
news:11******* **************@ p79g2000cwp.goo glegroups.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.Se lectedIndex=-1;
is it supposed to be uncommented?

happy to help if you can provide more info
tim
"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******* **************@ h48g2000cwc.goo glegroups.com.. .
Dear all ,

i am writting following code.

if(Page.IsPostB ack==false)
{
try
{

BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
// Defination of BindSectionDrop DownList
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();
reportCategory_ Dropdownlist.Da taTextField="Se ctionDesc";
reportCategory_ Dropdownlist.Da taValueField ="sectionId" ;
reportCategory_ Dropdownlist.Da taSource=dv;
reportCategory_ Dropdownlist.Da taBind();
reportCategory_ Dropdownlist.It ems.Insert(0,ne w
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop downlist.DataTe xtField="Sectio nDesc";
subSection_Drop downlist.DataVa lueField ="sectionId" ;
subSection_Drop downlist.DataSo urce=dv;
subSection_Drop downlist.DataBi nd();
subSection_Drop downlist.Items. Insert(0,new
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLineDesc _DropDownList.D ataTextField="S ectionLineDescr iption";
sectionLineDesc _DropDownList.D ataValueField ="SectionLineId ";
sectionLineDesc _DropDownList.D ataSource= dv;
sectionLineDesc _DropDownList.D ataBind();

sectionLineDesc _DropDownList.I tems.Insert(0,n ew
ListItem("--Select--","-1"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}

private void search_Button_C lick(object sender, System.EventArg s
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.

Sep 11 '06 #8
hi Tim_Mac

it is not like that say
if i select fifth item from the third list then after page is post
back it will lose selection from fifth to first item in the list.

Tim_Mac wrote:
hi Santosh,
when you say the index remains the same, do you mean when you change the
index to the 5th item (for example) that it stays on the 5th item after the
SelectedIndexCh anged event? or that it stays on the first 'Select...' item
after the event?

tim
"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@i 3g2000cwc.googl egroups.com...
Dear Tim

The selected index of first two lists remain same but only thirds are
change it change on
change List3 and and click search also.

please help me. what exactely wrong happen.
regards
Santosh

Tim_Mac wrote:
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 EnableViewState d = true and AutoPostBack=tr ue
set on all 3 drop down lists, and that the SelectedIndexCh anged 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

"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******** **************@ e3g2000cwe.goog legroups.com...
Here is code ..
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if(!Page.IsPost Back)
{
try
{
BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();

section_DropDow nList.DataTextF ield="SectionDe sc";
section_DropDow nList.DataValue Field ="sectionId" ;
section_DropDow nList.DataSourc e=dv;
section_DropDow nList.DataBind( );
section_DropDow nList.Items.Ins ert(0,new
ListItem("--Select--","--Select--"));

}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop DownList.DataTe xtField="Sectio nDesc";
subSection_Drop DownList.DataVa lueField ="sectionId" ;
subSection_Drop DownList.DataSo urce=dv;
subSection_Drop DownList.DataBi nd();
subSection_Drop DownList.Items. Insert(0,new
ListItem("--Select--","--Select--"));

}

private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLine_Dro pDownList.DataT extField="Secti onLineDescripti on";
sectionLine_Dro pDownList.DataV alueField ="SectionLineId ";
sectionLine_Dro pDownList.DataS ource= dv;
sectionLine_Dro pDownList.DataB ind();

sectionLine_Dro pDownList.Items .Insert(0,new
ListItem("--Select--","-1"));
}

private void section_DropDow nList_SelectedI ndexChanged(obj ect sender,
System.EventArg s e)
{
try
{
DataSet ds = new DataSet();
ds =
objSectionMaste r.GetSubSection RecForReports1( Convert.ToInt32 (section_DropDo wnList.Selected Value));
subSection_Drop DownList.DataTe xtField="Sectio nDesc";
subSection_Drop DownList.DataVa lueField ="SectionId" ;
subSection_Drop DownList.DataSo urce=ds;
subSection_Drop DownList.DataBi nd();
}
catch(Exception ex)
{
Response.Write( "<script language=javasc riptalert('"+
ex.Message.ToSt ring()+"');</script>");
}

private void subSection_Drop DownList_Select edIndexChanged( object
sender, System.EventArg s e)
{
try
{
if(subSection_D ropDownList.Sel ectedValue=="--Select--")
{
return;
}

DataView dv = new DataView();
dv =
objSectionMaste r.GetSectionLin esRecForReports (Convert.ToInt3 2(subSection_Dr opDownList.Sele ctedValue));
sectionLine_Dro pDownList.DataT extField="Secti onLineDescripti on";
sectionLine_Dro pDownList.DataV alueField ="SectionId" ;
sectionLine_Dro pDownList.DataS ource=dv;
sectionLine_Dro pDownList.DataB ind();

}
catch(Exception ex)
{
Response.Write( "<script language=javasc riptalert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
private void search_Button_C lick(object sender, System.EventArg s 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_SelectedI ndex_Changed Bind List 2
List2_SelectedI ndex_Changed Bind List 3
List3_SelectedI ndex_Changed Search whatever

have you got AutoPostBack=tr ue on all the lists? also, you haven't
posted
the SelectedIndexCh anged 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" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@p 79g2000cwp.goog legroups.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.Se lectedIndex=-1;
is it supposed to be uncommented?

happy to help if you can provide more info
tim
"Santosh" <Sa************ ***@yahoo.comwr ote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
Dear all ,

i am writting following code.

if(Page.IsPostB ack==false)
{
try
{

BindSectionDrop Downlist();
BindSubSectionD ropDownlist();
BindSectionLine DropDownlist();
}

catch(Exception ex)
{
Response.Write( "<script language=Javasc ript>alert('"+
ex.Message.ToSt ring()+"');</script>");
}
}
}
// Defination of BindSectionDrop DownList
private void BindSectionDrop Downlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSectionRec ForReports();
reportCategory_ Dropdownlist.Da taTextField="Se ctionDesc";
reportCategory_ Dropdownlist.Da taValueField ="sectionId" ;
reportCategory_ Dropdownlist.Da taSource=dv;
reportCategory_ Dropdownlist.Da taBind();
reportCategory_ Dropdownlist.It ems.Insert(0,ne w
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSubSectionD ropDownlist()
{
DataView dv = new DataView();
dv = objSectionMaste r.GetSubSection RecReports();
subSection_Drop downlist.DataTe xtField="Sectio nDesc";
subSection_Drop downlist.DataVa lueField ="sectionId" ;
subSection_Drop downlist.DataSo urce=dv;
subSection_Drop downlist.DataBi nd();
subSection_Drop downlist.Items. Insert(0,new
ListItem("--Select--","--Select--"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}
private void BindSectionLine DropDownlist()
{

DataView dv = new DataView();
dv = objSectionMaste r.GetSectionLin eRecReports();
sectionLineDesc _DropDownList.D ataTextField="S ectionLineDescr iption";
sectionLineDesc _DropDownList.D ataValueField ="SectionLineId ";
sectionLineDesc _DropDownList.D ataSource= dv;
sectionLineDesc _DropDownList.D ataBind();

sectionLineDesc _DropDownList.I tems.Insert(0,n ew
ListItem("--Select--","-1"));

//reportCategoty_ DropDownList.Se lectedIndex=-1;
}

private void search_Button_C lick(object sender, System.EventArg s
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.

Sep 12 '06 #9
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=tr ue?
the reason i ask is because you don't appear to have a SelectedIndexCh anged
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 InitialiseCompo nent code to make sure you have
wired the events correctly with the menus.

tim
Sep 12 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1119
by: Julie Barnet | last post by:
Can someone please post a small example of how to trap a selected index changed event from a dropdownlist in a datagrid? Thanks in advance Julie Barnet
5
13851
by: Steve Jones | last post by:
Hi there, I am working with web forms, and am finding that the standard list of combo box events is dramatically reduced when using the dropdownlist. For example, the only event that I can see that will trigger when a user selects a different menu item is 'selected index changed'. I can confirm with a separate button that the index has in fact changed after a pulldown selection takes place, yet the internal 'selected index changed'...
10
2743
by: Phuff | last post by:
Thanks in advance! I'm trying to maintain a dl list's selected index on postback. What I'm doing is when a person selects an item from the drop down list I select a date in a calendar control and populate a text box with the date. To do this I set auto postback to the drop down list. But it always resets the selected index on post back. I control for this in the onLoad method... If Not Page.IsPostBack Then If page is posted back...
0
1395
by: DCC700 | last post by:
After converting a web application to 2005, I am receiving an invalid character error when I change the value in a dropdown list. The dropdown list is set to postback on selected index changed and perform some actions. The postback is not happening due to this error on the page. All the dropdown lists on this page cause this error, but I use dropdowns on many other pages that do not have any problems. Any ideas??? *** Sent via...
2
1571
by: rocksoft | last post by:
Hi I am working in asp.net with C# web application, I have used visual studio 2003, i have used dropdownlist in my application to populate the data from mysql database, i have got problem while i selected the item from dropdownlist, its not selecting correct item i'm selecting from dropdownlist, i have 64 records in my table, but i tried to work with upto 15 records it will not giving problem, when the scroll will enable to dropdownlist...
1
2821
by: RK800 | last post by:
could someone help me out with this?? i am creating a dropdown(dd2) dynamically inside a <div> , on the selected index event of another dropdown(dd1). somehow i am not able to handle or get the selectedindexchange event of dd2. i get the values inside dd2, but does not respond to any event. i am using the code is as below. Function getdatafromdb(ByVal s As String) As String Try
5
21025
by: Kalkin | last post by:
Hi Is it possible to change the data source of a dropdown list in a gridview from another dropdown list selected index changed method in the same gridview? for example I have a dropdown that needs to change its contents depending on what is chosen in the previous cell of the gridview, which is also a dropdown list. Any Help would be much appreciated Thanks
0
2130
by: perumalsamy R | last post by:
I am using gridview in my project.When i am clicking the checkbox ,I want to add the price value on gridview selected index changed event.can you help for my problem please help me?
1
2472
by: kapil tripathi | last post by:
1) Accpet the item in TxtItem in comma seperated values like (Apple, Mango, Orange etc.). Store that item in array object (objArray) in acending order." 2) Create the object of the dropdown list objDropDwon on runtime and fill its items from objArray." 3) Create server side table and
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9342
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9211
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8218
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3286
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.