Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: DropDownList is Bugging


Message #1 by "J Donahue" <jdonahue@f...> on Thu, 13 Jun 2002 04:36:04
I'm going nuts.  I am moving some code from an ascx page into the aspx 
page (eliminating the ascx page altogether).  My dropdown list correctly 
picks up my selection the first time, but it will never change again if I 
want to select something else. (meaning if I pick Branch12 the first time 
and transfer back to itself, it will always show Branch12 even though I 
subsequently picked Branch 15).
In the aspx page, I have the following:

<asp:dropdownlist id="BranchList" CssClass="10bold" Runat="server" 
AutoPostBack="True" 
OnSelectedIndexChanged="EvaluateBranch"></asp:DropDownList>

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 
Handles MyBase.Load

  If Not Page.IsPostBack Then
          Dim objDataView As DataView
          strSQL = "SELECT BranchID, BranchNameVC FROM tBranches ORDER by 
BranchNameVC "
          objDataView = Glbl.GetDataView(strSQL, "tBranches")
          If IsNothing(objDataView) Then
             <MyError>
             Exit Sub	
          End If
          BranchList.DataSource = objDataView
          BranchList.DataValueField = "BranchID"
          BranchList.DataTextField = "BranchNameVC"
          BranchList.DataBind()
          BranchList.Items.Insert(0, "Select Branch")
  EndIf

  If Session("ReqBranchChose") <> Nothing Then
      BranchList.SelectedIndex = BranchList.Items.IndexOf
(BranchList.Items.FindByText(Session("ReqBranchChose")))
  End If

End Sub

Sub EvaluateBranch(ByVal sender As Object, ByVal e As EventArgs)    
    Session("ReqBranchChose") = BranchList.SelectedItem.Text
    Server.Transfer("RequestInp.aspx", False)  'simply calling itself back
End Sub

It works properly if I keep it in the ascx page (I can change my 
selection as many times as I want), but since I moved it into the aspx 
page, it only lets me make one selection and I'm stuck with it.  Can 
anyone tell me what I'm doing wrong?
Thanks...Jim
Message #2 by Philip Tham <philipt1@s...> on Wed, 12 Jun 2002 22:38:47 -0500
I run into the same problem before,  If I still remember correctly I  think
this is how I solved it.  1) try to convert 12,13....15 to integer  else 2)
try to insert a character like - before the number

Good luck

Philip
----- Original Message -----
From: "J Donahue" <jdonahue@f...>
To: "ASP+" <aspx@p...>
Sent: Wednesday, June 12, 2002 11:36 PM
Subject: [aspx] DropDownList is Bugging


> I'm going nuts.  I am moving some code from an ascx page into the aspx
> page (eliminating the ascx page altogether).  My dropdown list correctly
> picks up my selection the first time, but it will never change again if I
> want to select something else. (meaning if I pick Branch12 the first time
> and transfer back to itself, it will always show Branch12 even though I
> subsequently picked Branch 15).
> In the aspx page, I have the following:
>
> <asp:dropdownlist id="BranchList" CssClass="10bold" Runat="server"
> AutoPostBack="True"
> OnSelectedIndexChanged="EvaluateBranch"></asp:DropDownList>
>
> Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
> Handles MyBase.Load
>
>   If Not Page.IsPostBack Then
>           Dim objDataView As DataView
>           strSQL = "SELECT BranchID, BranchNameVC FROM tBranches ORDER by
> BranchNameVC "
>           objDataView = Glbl.GetDataView(strSQL, "tBranches")
>           If IsNothing(objDataView) Then
>              <MyError>
>              Exit Sub
>           End If
>           BranchList.DataSource = objDataView
>           BranchList.DataValueField = "BranchID"
>           BranchList.DataTextField = "BranchNameVC"
>           BranchList.DataBind()
>           BranchList.Items.Insert(0, "Select Branch")
>   EndIf
>
>   If Session("ReqBranchChose") <> Nothing Then
>       BranchList.SelectedIndex = BranchList.Items.IndexOf
> (BranchList.Items.FindByText(Session("ReqBranchChose")))
>   End If
>
> End Sub
>
> Sub EvaluateBranch(ByVal sender As Object, ByVal e As EventArgs)
>     Session("ReqBranchChose") = BranchList.SelectedItem.Text
>     Server.Transfer("RequestInp.aspx", False)  'simply calling itself back
> End Sub
>
> It works properly if I keep it in the ascx page (I can change my
> selection as many times as I want), but since I moved it into the aspx
> page, it only lets me make one selection and I'm stuck with it.  Can
> anyone tell me what I'm doing wrong?
> Thanks...Jim

Message #3 by "Li, Fang" <fang@c...> on Thu, 13 Jun 2002 10:37:04 -0400
If you call this page again like
>Server.Transfer("RequestInp.aspx", False)  'simply calling itself back 

the Page_Load() function will be called and code
>If Not Page.IsPostBack Then  
Will be true, then you bind all data again. I think that's the reason.
Try to debug it and see what happed.

-----Original Message-----
From: J Donahue [mailto:jdonahue@f...] 
Sent: Thursday, June 13, 2002 12:36 AM
To: ASP+
Subject: [aspx] DropDownList is Bugging


I'm going nuts.  I am moving some code from an ascx page into the aspx 
page (eliminating the ascx page altogether).  My dropdown list correctly 
picks up my selection the first time, but it will never change again if I 
want to select something else. (meaning if I pick Branch12 the first time 
and transfer back to itself, it will always show Branch12 even though I 
subsequently picked Branch 15).
In the aspx page, I have the following:

<asp:dropdownlist id="BranchList" CssClass="10bold" Runat="server" 
AutoPostBack="True" 
OnSelectedIndexChanged="EvaluateBranch"></asp:DropDownList>

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 
Handles MyBase.Load

  If Not Page.IsPostBack Then
          Dim objDataView As DataView
          strSQL = "SELECT BranchID, BranchNameVC FROM tBranches ORDER by 
BranchNameVC "
          objDataView = Glbl.GetDataView(strSQL, "tBranches")
          If IsNothing(objDataView) Then
             <MyError>
             Exit Sub	
          End If
          BranchList.DataSource = objDataView
          BranchList.DataValueField = "BranchID"
          BranchList.DataTextField = "BranchNameVC"
          BranchList.DataBind()
          BranchList.Items.Insert(0, "Select Branch")
  EndIf

  If Session("ReqBranchChose") <> Nothing Then
      BranchList.SelectedIndex = BranchList.Items.IndexOf
(BranchList.Items.FindByText(Session("ReqBranchChose")))
  End If

End Sub

Sub EvaluateBranch(ByVal sender As Object, ByVal e As EventArgs)    
    Session("ReqBranchChose") = BranchList.SelectedItem.Text
    Server.Transfer("RequestInp.aspx", False)  'simply calling itself back
End Sub

It works properly if I keep it in the ascx page (I can change my 
selection as many times as I want), but since I moved it into the aspx 
page, it only lets me make one selection and I'm stuck with it.  Can 
anyone tell me what I'm doing wrong?
Thanks...Jim
Message #4 by "J Donahue" <jdonahue@f...> on Thu, 13 Jun 2002 16:00:13
Thx Li but the reason it's bugging is not due to the post back (whether 
rebinding or not).  I checked this by setting a session variable and then 
setting the default item based on that session variable AFTER it getst 
the dropdown items.
For some reason, my session variable is not changing for the new selection

> 
If you call this page again like
>Server.Transfer("RequestInp.aspx", False)  'simply calling itself back 

the Page_Load() function will be called and code
>If Not Page.IsPostBack Then  
Will be true, then you bind all data again. I think that's the reason.
Try to debug it and see what happed.

-----Original Message-----
From: J Donahue [mailto:jdonahue@f...] 
Sent: Thursday, June 13, 2002 12:36 AM
To: ASP+
Subject: [aspx] DropDownList is Bugging


I'm going nuts.  I am moving some code from an ascx page into the aspx 
page (eliminating the ascx page altogether).  My dropdown list correctly 
picks up my selection the first time, but it will never change again if I 
want to select something else. (meaning if I pick Branch12 the first time 
and transfer back to itself, it will always show Branch12 even though I 
subsequently picked Branch 15).
In the aspx page, I have the following:

<asp:dropdownlist id="BranchList" CssClass="10bold" Runat="server" 
AutoPostBack="True" 
OnSelectedIndexChanged="EvaluateBranch"></asp:DropDownList>

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 
Handles MyBase.Load

  If Not Page.IsPostBack Then
          Dim objDataView As DataView
          strSQL = "SELECT BranchID, BranchNameVC FROM tBranches ORDER by 
BranchNameVC "
          objDataView = Glbl.GetDataView(strSQL, "tBranches")
          If IsNothing(objDataView) Then
             <MyError>
             Exit Sub	
          End If
          BranchList.DataSource = objDataView
          BranchList.DataValueField = "BranchID"
          BranchList.DataTextField = "BranchNameVC"
          BranchList.DataBind()
          BranchList.Items.Insert(0, "Select Branch")
  EndIf

  If Session("ReqBranchChose") <> Nothing Then
      BranchList.SelectedIndex = BranchList.Items.IndexOf
(BranchList.Items.FindByText(Session("ReqBranchChose")))
  End If

End Sub

Sub EvaluateBranch(ByVal sender As Object, ByVal e As EventArgs)    
    Session("ReqBranchChose") = BranchList.SelectedItem.Text
    Server.Transfer("RequestInp.aspx", False)  'simply calling itself back
End Sub

It works properly if I keep it in the ascx page (I can change my 
selection as many times as I want), but since I moved it into the aspx 
page, it only lets me make one selection and I'm stuck with it.  Can 
anyone tell me what I'm doing wrong?
Thanks...Jim
Message #5 by "Li, Fang" <fang@c...> on Thu, 13 Jun 2002 11:57:48 -0400
Hi Jim,
How about try to past the selected index as parameter to the new this page,
it works for me. 
Fang

-----Original Message-----
From: J Donahue [mailto:jdonahue@f...] 
Sent: Thursday, June 13, 2002 12:00 PM
To: ASP+
Subject: [aspx] RE: DropDownList is Bugging


Thx Li but the reason it's bugging is not due to the post back (whether 
rebinding or not).  I checked this by setting a session variable and then 
setting the default item based on that session variable AFTER it getst 
the dropdown items.
For some reason, my session variable is not changing for the new selection

> 
If you call this page again like
>Server.Transfer("RequestInp.aspx", False)  'simply calling itself back

the Page_Load() function will be called and code
>If Not Page.IsPostBack Then
Will be true, then you bind all data again. I think that's the reason. Try
to debug it and see what happed.

-----Original Message-----
From: J Donahue [mailto:jdonahue@f...] 
Sent: Thursday, June 13, 2002 12:36 AM
To: ASP+
Subject: [aspx] DropDownList is Bugging


I'm going nuts.  I am moving some code from an ascx page into the aspx 
page (eliminating the ascx page altogether).  My dropdown list correctly 
picks up my selection the first time, but it will never change again if I 
want to select something else. (meaning if I pick Branch12 the first time 
and transfer back to itself, it will always show Branch12 even though I 
subsequently picked Branch 15).
In the aspx page, I have the following:

<asp:dropdownlist id="BranchList" CssClass="10bold" Runat="server" 
AutoPostBack="True" 
OnSelectedIndexChanged="EvaluateBranch"></asp:DropDownList>

Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 
Handles MyBase.Load

  If Not Page.IsPostBack Then
          Dim objDataView As DataView
          strSQL = "SELECT BranchID, BranchNameVC FROM tBranches ORDER by 
BranchNameVC "
          objDataView = Glbl.GetDataView(strSQL, "tBranches")
          If IsNothing(objDataView) Then
             <MyError>
             Exit Sub	
          End If
          BranchList.DataSource = objDataView
          BranchList.DataValueField = "BranchID"
          BranchList.DataTextField = "BranchNameVC"
          BranchList.DataBind()
          BranchList.Items.Insert(0, "Select Branch")
  EndIf

  If Session("ReqBranchChose") <> Nothing Then
      BranchList.SelectedIndex = BranchList.Items.IndexOf
(BranchList.Items.FindByText(Session("ReqBranchChose")))
  End If

End Sub

Sub EvaluateBranch(ByVal sender As Object, ByVal e As EventArgs)    
    Session("ReqBranchChose") = BranchList.SelectedItem.Text
    Server.Transfer("RequestInp.aspx", False)  'simply calling itself back
End Sub

It works properly if I keep it in the ascx page (I can change my 
selection as many times as I want), but since I moved it into the aspx 
page, it only lets me make one selection and I'm stuck with it.  Can 
anyone tell me what I'm doing wrong?
Thanks...Jim

  Return to Index