By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,012 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,012 IT Pros & Developers. It's quick & easy.

populating dynamic user control (ascx)

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Wat value will be same? Are you handling the postback correctly.
--
Girish Bharadwaj
http://msmvps.com/gbvb
"John Ninan" <Jo*******@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
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

Nov 18 '05 #2

P: n/a
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

"Girish Bharadwaj" wrote:
Wat value will be same? Are you handling the postback correctly.
--
Girish Bharadwaj
http://msmvps.com/gbvb
"John Ninan" <Jo*******@discussions.microsoft.com> wrote in message
news:29**********************************@microsof t.com...
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


Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.