473,320 Members | 1,839 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,320 software developers and data experts.

populating dynamic user control (ascx)

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
2 3323
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Steven | last post by:
From a fairly good understanding of traditional ASP I am taking my first tentative steps into C#. Within Visual Studio, my first test is as follows: Default.aspx contains a placeholder...
3
by: Stu | last post by:
Hi, I am creating a control in a PlaceHolder like so: Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim ctrl As...
1
by: Steve Booth | last post by:
I have a web form containing a button that when selected adds a user control to a place holder. The user control contains a button. The first time the user control is added the contained button...
0
by: jonelling | last post by:
I am having a problem where the page load event is not being fired for certain user controls that I load dynamically in placeholders. Here is what I'm doing in brief, with full test code supplied...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
4
by: rn5a | last post by:
Assume that a ASPX page uses a user control named Address.ascx which has 2 TextBoxes. This ASCX page creates 2 properties named 'Address' & 'City' using the Get & Set statements: <script...
2
by: germ | last post by:
I am moving a web application from 1.1 to 2.0 This site builds pages dynamically as : PlaceHolder.Controls.Add(LoadControl("~/Controls/Ctl1.ascx")); Everything is working fine as long as the web...
0
by: CMELLO | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
0
by: =?Utf-8?B?Y2luZHk=?= | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.