 |
| ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 5th, 2004, 09:39 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Form Problems
I have a form that builds programatically based on certain conditions. When I click submit to input the data entered into the database I get this error message:
Object reference not set to an instance of an object.
on this line:
dbComm.Parameters("category").Value = drpDwnCategory.SelectedValue
Also note that I have split up the form because it's long into panels. panel1 gets the first 7 questions, panel2 gets the next 7 and panel3 gets the final 8 questions. I'm sending the form controls to 2 placeholders. The final 8 questions are the same for every form so I just added them in the panel3 and they are not programably built. The values from panel3 can be retrieved.
Is there something I need to do for the programmably built controls to make sure they are maintained throughout the form?
|
|

February 5th, 2004, 09:58 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
r they in deffrent pages or u just parted them by ur panels? if so, do u save the previous page's items??
Always:),
Hovik Melkomian.
|
|

February 5th, 2004, 10:02 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
I set their visible property to false and the next panel to true like this:
Dim pnlPanel As Panel
Dim strPanelName As String
' Hide Previous Panel
strPanelName = "pnlForm" & ViewState("CurrentPage")
pnlPanel = FindControl(strPanelName)
pnlPanel.Visible = False
' Show Current Panel
ViewState("CurrentPage") += 1
strPanelName = "pnlForm" & ViewState("CurrentPage")
pnlPanel = FindControl(strPanelName)
pnlPanel.Visible = True
When you say save do you mean update the database with the info?
|
|

February 5th, 2004, 10:13 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
i still dont know ur project style? do u use more than 1 page or not?!
Always:),
Hovik Melkomian.
|
|

February 5th, 2004, 10:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
It's only one page.
|
|

February 5th, 2004, 10:42 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
It seems ur script is wrong! Shouldnt u use
dbComm.Parameters("category").Value = drpDwnCategory.SelectedItem.Value;
if u have filled Text & value of ur DropDownList?!
keep in touch.
Always:),
Hovik Melkomian.
|
|

February 5th, 2004, 10:54 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
That didn't work. There are 20 possible combinations of questions and when i first started trying to code it I created 20 pages and built the form by hand and it worked. But I wanted one page to accomplish it but the error was returned when submit was clicked.
So, I wondering if building controls there is one step that I left out.
Here is a snipit of code from the Form Builder:
Select Case strQuestion.ToUpper
Case "Please Select a Category.".ToUpper
Dim myQuestion As New Label
myQuestion.Text = strQuestion & "<br>"
Dim myCategory As New DropDownList
myCategory.ID = "drpDwnCategory"
myCategory.Items.Add("No")
myCatHolder.Controls.Add(myQuestion)
myCatHolder.Controls.Add(myCategory)
Case "Approximately how many square feet is your project?".ToUpper
Dim myQuestion As New Label
myQuestion.Text = "<br><br>" & strQuestion & "<br>"
Dim myTextBox As New TextBox
myTextBox.ID = "txtSquareFt"
myTextBox.Width = New Unit(100)
myCatHolder.Controls.Add(myQuestion)
myCatHolder.Controls.Add(myTextBox)
|
|

February 5th, 2004, 10:56 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
If it goes into Panel2 the 'myCatHolder' changes to 'myCatHolder2'
i.e.
myCatHolder2.Controls.Add(myQuestion)
myCatHolder2.Controls.Add(myTextBox)
|
|

February 5th, 2004, 12:23 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
- Where are you building the controls (in what function, what point of the page execution)?
- How and at what point in execution are the controls reaching their final parent control? This may have a great impact on the problem.
Peter
------------------------------------------------------
Work smarter, not harder.
|
|

February 5th, 2004, 12:40 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
ViewState("CurrentPage") = 1
Label1.Text = getCategory()
End If
getQuestions()
'getCats()
End Sub
getCategory executes first and returns a single text like Additions.
getQuestions takes 'Additions' and pulls all questions related to 'Additions' and adds them to the form panels. The controls are reaching the myCatHolder1 and 2 when the functions runs. myCatHolder1 and 2 reside in panel 1 and 2 respectively. If you need me to post the code let me know.
|
|
 |