populating dynamic user control (ascx)

G

Guest

I am creating Dynamic Usercontrol in Asp.net application. In this application
I have a combobox(aspx Page). Which contains various items. Based on item
selected I am dynamically populating Usercontrols.
Problem:
When I am populating dynamic user control (ascx) page in Page_load event it
works fine for the first list item from combobox. When I change the item in
combobox, usercontrols are build properly but value will be same in second
page as first page. I debug and found that new value is assigned but in
control it is not changing. I have no idea what’s going on?

Thanks in advance for any thoughts.
John Ninan
 
G

Guest

Thanks Girish,

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top