D
DOUGLAS HEESTAND
I have a simple web app I am building: a user fills out a simple form
(regform.aspx) and clicks "OK" and they get a confirmation page
(confirmation.aspx) that repeats back what they entered before they
move on. I want the user to be able to go back to the first page from
the confirmation page and change values if they want. Seems simple,
no? I was going to use session state to pre-fill in the values on the
simple form on page_load if they are returning to it from the
confirmation page. I can do this for textboxes but when I try it for
a dropdown list I get ""Object reference not set to an instance of an
object." Here is a simplified version of my code. Thanks for any
help in advance:
RegForm.aspx
-------------
<%@ Page Language="VB" Inherits="RegFormCodeBehind"
Src="RegForm.aspx.vb" %>
<form name="RegForm" method="post" action="RegForm.aspx"
runat="server">
<asp:textbox ID="txtName" runat="server" /><br>
<asp:dropdownlist ID="ddlAge" runat="server">
<asp:listitem>Choose one...</asp:listitem>
<asp:listitem Value="25">25</asp:listitem>
<asp:listitem Value="26">27</asp:listitem>
</asp:dropdownlist>
....
RegForm.aspx
-------------
Public Class RegFormCodeBehind
Inherits System.Web.UI.Page
Public txtName as Textbox
Public ddlYear as Dropdownlist
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
txtName.Text = "test value"
ddlAge.SelectedIndex = 1
End Sub
End Class
How do you set dropdownlists from code?
Thanks in advance!
-----------------
(regform.aspx) and clicks "OK" and they get a confirmation page
(confirmation.aspx) that repeats back what they entered before they
move on. I want the user to be able to go back to the first page from
the confirmation page and change values if they want. Seems simple,
no? I was going to use session state to pre-fill in the values on the
simple form on page_load if they are returning to it from the
confirmation page. I can do this for textboxes but when I try it for
a dropdown list I get ""Object reference not set to an instance of an
object." Here is a simplified version of my code. Thanks for any
help in advance:
RegForm.aspx
-------------
<%@ Page Language="VB" Inherits="RegFormCodeBehind"
Src="RegForm.aspx.vb" %>
<form name="RegForm" method="post" action="RegForm.aspx"
runat="server">
<asp:textbox ID="txtName" runat="server" /><br>
<asp:dropdownlist ID="ddlAge" runat="server">
<asp:listitem>Choose one...</asp:listitem>
<asp:listitem Value="25">25</asp:listitem>
<asp:listitem Value="26">27</asp:listitem>
</asp:dropdownlist>
....
RegForm.aspx
-------------
Public Class RegFormCodeBehind
Inherits System.Web.UI.Page
Public txtName as Textbox
Public ddlYear as Dropdownlist
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
txtName.Text = "test value"
ddlAge.SelectedIndex = 1
End Sub
End Class
How do you set dropdownlists from code?
Thanks in advance!
-----------------