473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

User control Error - Help

In my aspx Page i have asp.net combobox. It has different values. So i am
generating usercontrol based on that. For example i have different flight leg
in my combobox. I select first flight leg , it populate usercontrol times 6
because it has 6 passenger.
Second time i select 2nd flight leg it has 2 usercontorl.

The usercontrol will populate correctly. But the value inside usercontrl is
not changing. I try to debug it . It seems, it is assigning the value but
messing up to show the value. Some how it is getting the value from first
flight leg.

here is my code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' This page allows the user to add/edit/delete reservations for
' for each leg of the flight. The user can navigate here from
' either the general passenger manifest or a specific leg's
' passenger manifest.

' Initializing login user id required every time page is loaded
loginUserID = CType(HttpContext.Current.Items("UserID"), Integer)

' Get FlightID
If Not Session("FlightID") Is Nothing Then
flightID = Session("FlightID")

' If not page postback do following else get leg id from ViewState
If Not Page.IsPostBack Then

' See if you can get the specific flightLegID
If Not Session("FlightLegID") Is Nothing Then
flightLegID = Session("FlightLegID")
Session.Remove("FlightLegID")
End If

' Get FlightLegs and put their numbers in dlstLeg
Dim ds As DataSet = fltLegBusiness.GetFlightLegs(flightID)
Dim dRow As DataRow
If Not ds Is Nothing AndAlso ds.Tables(0).Rows.Count > 0 Then
dlstLeg.DataSource = ds
dlstLeg.DataTextField = "iLegNumber"
dlstLeg.DataValueField = "iFlightLegID"
dlstLeg.DataBind()

' Make sure right flightLegID is highlighted and save
leg ID
If flightLegID > 0 Then
Dim dItem As ListItem =
dlstLeg.Items.FindByValue(flightLegID)
If Not dItem Is Nothing Then
dlstLeg.ClearSelection()
dItem.Selected = True
Else
flightLegID = dlstLeg.SelectedItem.Value
End If
Else
flightLegID = dlstLeg.SelectedItem.Value
End If
Else
' Warn user if no flight legs available for setting
reservations

Response.Redirect("../../ErrorReport.aspx?Source=Passenger Reservations
Page/Functionality&Message=Flight has no legs available for Crew
Reservations")
End If
Else
If Not ViewState("FlightLegID") Is Nothing Then
flightLegID = ViewState("FlightLegID")
Else

Response.Redirect("../../ErrorReport.aspx?Source=Passenger Reservations
Page/Functionality&Message=Cannot find flight leg for Passenger Reservations")
End If
End If
'' PopulateResv
'this procedure, will create different flight leg detail usercontrol.
Me.PopulateReservations()
Else
Response.Redirect("../../ErrorReport.aspx?Source=Passenger
Reservations Page/Functionality&Message=Cannot determine Flight for Passenger
Reservations")
End If
End Sub

Nov 18 '05 #1
1 1372
Hi,

Most probably the code for initializing the control gets executed *before*
the handler of the SelectedIndexChanged of the DropDownList. I suggest you
move the initialization code of your UserControl from the Page_Load handler
to a new method and call this method from the
DropDownList.SelectedIndexChanged handler (it might be convenient to pass
the selected value as a parameter to this method).

Hope this helps
Martin
"John Ninan" <Jo*******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
In my aspx Page i have asp.net combobox. It has different values. So i am
generating usercontrol based on that. For example i have different flight leg in my combobox. I select first flight leg , it populate usercontrol times 6 because it has 6 passenger.
Second time i select 2nd flight leg it has 2 usercontorl.

The usercontrol will populate correctly. But the value inside usercontrl is not changing. I try to debug it . It seems, it is assigning the value but
messing up to show the value. Some how it is getting the value from first
flight leg.

here is my code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' This page allows the user to add/edit/delete reservations for
' for each leg of the flight. The user can navigate here from
' either the general passenger manifest or a specific leg's
' passenger manifest.

' Initializing login user id required every time page is loaded
loginUserID = CType(HttpContext.Current.Items("UserID"), Integer)

' Get FlightID
If Not Session("FlightID") Is Nothing Then
flightID = Session("FlightID")

' If not page postback do following else get leg id from ViewState If Not Page.IsPostBack Then

' See if you can get the specific flightLegID
If Not Session("FlightLegID") Is Nothing Then
flightLegID = Session("FlightLegID")
Session.Remove("FlightLegID")
End If

' Get FlightLegs and put their numbers in dlstLeg
Dim ds As DataSet = fltLegBusiness.GetFlightLegs(flightID)
Dim dRow As DataRow
If Not ds Is Nothing AndAlso ds.Tables(0).Rows.Count > 0 Then dlstLeg.DataSource = ds
dlstLeg.DataTextField = "iLegNumber"
dlstLeg.DataValueField = "iFlightLegID"
dlstLeg.DataBind()

' Make sure right flightLegID is highlighted and save
leg ID
If flightLegID > 0 Then
Dim dItem As ListItem =
dlstLeg.Items.FindByValue(flightLegID)
If Not dItem Is Nothing Then
dlstLeg.ClearSelection()
dItem.Selected = True
Else
flightLegID = dlstLeg.SelectedItem.Value
End If
Else
flightLegID = dlstLeg.SelectedItem.Value
End If
Else
' Warn user if no flight legs available for setting reservations

Response.Redirect("../../ErrorReport.aspx?Source=Passenger Reservations
Page/Functionality&Message=Flight has no legs available for Crew
Reservations")
End If
Else
If Not ViewState("FlightLegID") Is Nothing Then
flightLegID = ViewState("FlightLegID")
Else

Response.Redirect("../../ErrorReport.aspx?Source=Passenger Reservations
Page/Functionality&Message=Cannot find flight leg for Passenger Reservations") End If
End If
'' PopulateResv
'this procedure, will create different flight leg detail usercontrol.
Me.PopulateReservations()
Else
Response.Redirect("../../ErrorReport.aspx?Source=Passenger
Reservations Page/Functionality&Message=Cannot determine Flight for Passenger Reservations")
End If
End Sub

Nov 18 '05 #2

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

Similar topics

1
by: Martine | last post by:
Hi there! I have a problem with programmatically adding user controls to my mobile webforms. If I load my usercontrol programmatically (in the Page_Load), the object is instantiated, I have...
5
by: Simon Harris | last post by:
Hi All, I am trying to call a method in a web form, from an event fired in a user control. My user control displays a map, which has a link button to enlarge/shrink the map. When the user...
2
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
0
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
3
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
0
by: Tom | last post by:
I am having a really annoying issue with serialization and a .NET User Control I am writing. For example, let's say I have a couple of classes in my control - first class is like: Public Class...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: davidr | last post by:
Hi, I have a panel that I load user Control in no problem. The problem arrises when I do a post back on one of these user controls. I have button it does a click event. In this click event I...
3
by: Jonathan Wood | last post by:
I could really use some help on this. First of all, I want to create a Web control where I render the control completely from scratch based on information from a database. In the book...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.