Hi There,
I am trying to write the selected value of a listcontrol when a button is
clicked and I keep getting the error "object not set to a reference of an
object". The libox itself is in a usercontrol and all i'm really needing to
do is get the selected value when the button is clicked on the form.
Can someone tell what I need to include in my page to get this working ?
Moe <><
!-- response.write
response.write (lstS.selectedI tem.tostring())
response.end
!-- class function
Public Class CommonFunctions
Public Shared Function BindStates() as SqlDataReader
Dim myConnection as New
SqlConnection(C onfigurationSet tings.AppSettin gs("connectionS tring"))
Const strSQL as String = "SELECT LocationID, Location AS
Location " & _
"FROM tbLocation ORDER BY
Location"
Dim myCommand as New SqlCommand(strS QL, myConnection)
myConnection.Op en()
Dim objDR as SqlDataReader
objDR = myCommand.Execu teReader(Comman dBehavior.Close Connection)
Return objDr
End Function
End Class
!-- bind the contro
lstS.DataSource = CommonFunctions .BindStates
lstS.DataBind()
lstS.Items.Inse rt(0, new ListItem("By State","0"))
!- lisbox on page
<asp:listbox id="lstS" runat="server" rows=1
DataTextField=" Location" DataValueField= "LocationID "/> 9 2180
Moe,
First I am assuming that you aren't trying to repsponse.write the value
until after it's selected. You'll get the object reference error right away
otherwise since no value has been selected yet.
Second, you need to make certain that the code populating the list only
fires on page load. If not, it is resetting the list every time. Do this
with the following if then:
If Not Page.IsPostBack Then
'---Populate list only once here
End If
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Moe Sizlak" <mo*@moe.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. Hi There,
I am trying to write the selected value of a listcontrol when a button is clicked and I keep getting the error "object not set to a reference of an object". The libox itself is in a usercontrol and all i'm really needing
to do is get the selected value when the button is clicked on the form.
Can someone tell what I need to include in my page to get this working ?
Moe <><
!-- response.write
response.write (lstS.selectedI tem.tostring())
response.end
!-- class function
Public Class CommonFunctions Public Shared Function BindStates() as SqlDataReader
Dim myConnection as New SqlConnection(C onfigurationSet tings.AppSettin gs("connectionS tring")) Const strSQL as String = "SELECT LocationID, Location AS Location " & _ "FROM tbLocation ORDER BY Location" Dim myCommand as New SqlCommand(strS QL, myConnection) myConnection.Op en() Dim objDR as SqlDataReader objDR = myCommand.Execu teReader(Comman dBehavior.Close Connection) Return objDr End Function End Class
!-- bind the contro
lstS.DataSource = CommonFunctions .BindStates lstS.DataBind() lstS.Items.Inse rt(0, new ListItem("By State","0"))
!- lisbox on page
<asp:listbox id="lstS" runat="server" rows=1 DataTextField=" Location" DataValueField= "LocationID "/>
Hi Justin,
I have the listmenu on the page and I do make sure that the menu is selected
before clicking the button, the load sud where I bind the list is in the
user control. Would this make a difference?
Moe
Sub Page_Load(byVal obj As Object, byVal e As EventArgs)
If Not Page.IsPostBack Then
lstS.DataSource = CommonFunctions .BindStates
lstS.DataBind()
lstS.Items.Inse rt(0, new ListItem("By State","0"))
End If
End Sub
"S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in message
news:10******** *****@corp.supe rnews.com... Moe,
First I am assuming that you aren't trying to repsponse.write the value until after it's selected. You'll get the object reference error right
away otherwise since no value has been selected yet.
Second, you need to make certain that the code populating the list only fires on page load. If not, it is resetting the list every time. Do this with the following if then:
If Not Page.IsPostBack Then '---Populate list only once here End If
-- Sincerely,
S. Justin Gengo, MCP Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order." Nietzsche "Moe Sizlak" <mo*@moe.com> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. .. Hi There,
I am trying to write the selected value of a listcontrol when a button
is clicked and I keep getting the error "object not set to a reference of
an object". The libox itself is in a usercontrol and all i'm really needing to do is get the selected value when the button is clicked on the form.
Can someone tell what I need to include in my page to get this working ?
Moe <><
!-- response.write
response.write (lstS.selectedI tem.tostring())
response.end
!-- class function
Public Class CommonFunctions Public Shared Function BindStates() as SqlDataReader
Dim myConnection as New SqlConnection(C onfigurationSet tings.AppSettin gs("connectionS tring")) Const strSQL as String = "SELECT LocationID, Location AS Location " & _ "FROM tbLocation ORDER BY Location" Dim myCommand as New SqlCommand(strS QL, myConnection) myConnection.Op en() Dim objDR as SqlDataReader objDR =
myCommand.Execu teReader(Comman dBehavior.Close Connection) Return objDr End Function End Class
!-- bind the contro
lstS.DataSource = CommonFunctions .BindStates lstS.DataBind() lstS.Items.Inse rt(0, new ListItem("By State","0"))
!- lisbox on page
<asp:listbox id="lstS" runat="server" rows=1 DataTextField=" Location" DataValueField= "LocationID "/>
Moe,
No, that looks good. It shouldn't make a difference that it's in a user
control.
Are you adding the user control to the page dynamically?
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Moe Sizlak" <mo*@moe.com> wrote in message
news:e%******** ********@TK2MSF TNGP09.phx.gbl. .. Hi Justin,
I have the listmenu on the page and I do make sure that the menu is
selected before clicking the button, the load sud where I bind the list is in the user control. Would this make a difference?
Moe
Sub Page_Load(byVal obj As Object, byVal e As EventArgs) If Not Page.IsPostBack Then lstS.DataSource = CommonFunctions .BindStates lstS.DataBind() lstS.Items.Inse rt(0, new ListItem("By State","0")) End If End Sub
"S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in message news:10******** *****@corp.supe rnews.com... Moe,
First I am assuming that you aren't trying to repsponse.write the value until after it's selected. You'll get the object reference error right away otherwise since no value has been selected yet.
Second, you need to make certain that the code populating the list only fires on page load. If not, it is resetting the list every time. Do this with the following if then:
If Not Page.IsPostBack Then '---Populate list only once here End If
-- Sincerely,
S. Justin Gengo, MCP Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order." Nietzsche "Moe Sizlak" <mo*@moe.com> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. .. Hi There,
I am trying to write the selected value of a listcontrol when a button is clicked and I keep getting the error "object not set to a reference of an object". The libox itself is in a usercontrol and all i'm really
needing to do is get the selected value when the button is clicked on the form.
Can someone tell what I need to include in my page to get this working
? Moe <><
!-- response.write
response.write (lstS.selectedI tem.tostring())
response.end
!-- class function
Public Class CommonFunctions Public Shared Function BindStates() as SqlDataReader
Dim myConnection as New SqlConnection(C onfigurationSet tings.AppSettin gs("connectionS tring")) Const strSQL as String = "SELECT LocationID, Location
AS Location " & _ "FROM tbLocation ORDER BY Location" Dim myCommand as New SqlCommand(strS QL, myConnection) myConnection.Op en() Dim objDR as SqlDataReader objDR =
myCommand.Execu teReader(Comman dBehavior.Close Connection) Return objDr End Function End Class
!-- bind the contro
lstS.DataSource = CommonFunctions .BindStates lstS.DataBind() lstS.Items.Inse rt(0, new ListItem("By State","0"))
!- lisbox on page
<asp:listbox id="lstS" runat="server" rows=1 DataTextField=" Location" DataValueField= "LocationID "/>
Hi Justin,
The control I am using is "includes/_control_conten t.ascx" and I just
include it in the main page. What else could it be?
Sean
<% @Import Namespace="Syst em.Data" %>
<% @Import Namespace="Syst em.Data.SqlClie nt" %>
<% @Import Namespace="Syst em.Web.UI.WebCo ntrols.DropDown List" %>
<%@ Import Namespace="Syst em.Web.UI.WebCo ntrols.CheckBox " %>
<%@ Register TagPrefix="User Control2" TagName="PlaceH eader"
Src="includes/_placelistingsu ser_header.ascx " %>
<%@ Register TagPrefix="User Control3" TagName="Contro l"
Src="includes/_control_conten t.ascx" %>
<%@ Register TagPrefix="User Control4" TagName="FormLi st"
Src="includes/_formlist_conte nt.ascx" %>
<link rel="stylesheet " type="text/css" href=">
<script language="vb" runat="server">
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="distribut ion" content="global ">
<meta name="revisit-after" content="14 days">
<meta name="ROBOTS" content="ALL">
<title>title</title>
</head>
<form enctype="multip art/form-data" runat="server">
<body topmargin="0" marginheight="0 " marginwidth="0" >
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
<td colspan="2" valign=top><Use rControl2:Place Header runat="server"
/></td>
<tr>
<td width="563" valign=top style="padding-left:40px "><div align=left
class=formtext sty style="padding-left:8px "></div><br><UserCo ntrol3:Control
runat="server" /></td>
<td>2</td>
</tr>
<TR>
<td colspan=2>  ;</td>
<td>
</tr>
</table>
</form>
</body>
</html>
"S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in message
news:10******** *****@corp.supe rnews.com... Moe,
No, that looks good. It shouldn't make a difference that it's in a user control.
Are you adding the user control to the page dynamically?
-- Sincerely,
S. Justin Gengo, MCP Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order." Nietzsche "Moe Sizlak" <mo*@moe.com> wrote in message news:e%******** ********@TK2MSF TNGP09.phx.gbl. .. Hi Justin,
I have the listmenu on the page and I do make sure that the menu is selected before clicking the button, the load sud where I bind the list is in the user control. Would this make a difference?
Moe
Sub Page_Load(byVal obj As Object, byVal e As EventArgs) If Not Page.IsPostBack Then lstS.DataSource = CommonFunctions .BindStates lstS.DataBind() lstS.Items.Inse rt(0, new ListItem("By State","0")) End If End Sub
"S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in message news:10******** *****@corp.supe rnews.com... Moe,
First I am assuming that you aren't trying to repsponse.write the
value until after it's selected. You'll get the object reference error right away otherwise since no value has been selected yet.
Second, you need to make certain that the code populating the list
only fires on page load. If not, it is resetting the list every time. Do
this with the following if then:
If Not Page.IsPostBack Then '---Populate list only once here End If
-- Sincerely,
S. Justin Gengo, MCP Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order." Nietzsche "Moe Sizlak" <mo*@moe.com> wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. .. > Hi There, > > I am trying to write the selected value of a listcontrol when a
button is > clicked and I keep getting the error "object not set to a reference
of an > object". The libox itself is in a usercontrol and all i'm really needing to > do is get the selected value when the button is clicked on the form. > > Can someone tell what I need to include in my page to get this
working ? > > Moe <>< > > !-- response.write > > response.write (lstS.selectedI tem.tostring()) > > response.end > > > !-- class function > > Public Class CommonFunctions > Public Shared Function BindStates() as SqlDataReader > > Dim myConnection as New > SqlConnection(C onfigurationSet tings.AppSettin gs("connectionS tring")) > Const strSQL as String = "SELECT LocationID, Location AS > Location " & _ > "FROM tbLocation ORDER
BY > Location" > Dim myCommand as New SqlCommand(strS QL, myConnection) > myConnection.Op en() > Dim objDR as SqlDataReader > objDR = myCommand.Execu teReader(Comman dBehavior.Close Connection) > Return objDr > End Function > End Class > > !-- bind the contro > > lstS.DataSource = CommonFunctions .BindStates > lstS.DataBind() > lstS.Items.Inse rt(0, new ListItem("By State","0")) > > !- lisbox on page > > <asp:listbox id="lstS" runat="server" rows=1 > DataTextField=" Location"
DataValueField= "LocationID "/> > >
Hi Justin,
Any other ideas? have a forgotten to declare something in my page?
"Moe Sizlak" <mo*@moe.com> wrote in message
news:uD******** ******@TK2MSFTN GP10.phx.gbl... Hi Justin,
The control I am using is "includes/_control_conten t.ascx" and I just include it in the main page. What else could it be?
Sean
<% @Import Namespace="Syst em.Data" %> <% @Import Namespace="Syst em.Data.SqlClie nt" %> <% @Import Namespace="Syst em.Web.UI.WebCo ntrols.DropDown List" %> <%@ Import Namespace="Syst em.Web.UI.WebCo ntrols.CheckBox " %> <%@ Register TagPrefix="User Control2" TagName="PlaceH eader" Src="includes/_placelistingsu ser_header.ascx " %> <%@ Register TagPrefix="User Control3" TagName="Contro l" Src="includes/_control_conten t.ascx" %> <%@ Register TagPrefix="User Control4" TagName="FormLi st" Src="includes/_formlist_conte nt.ascx" %> <link rel="stylesheet " type="text/css" href="> <script language="vb" runat="server"> </script>
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="distribut ion" content="global "> <meta name="revisit-after" content="14 days"> <meta name="ROBOTS" content="ALL">
<title>title</title> </head> <form enctype="multip art/form-data" runat="server"> <body topmargin="0" marginheight="0 " marginwidth="0" > <table width="100%" border="0" cellpadding="0" cellspacing="0" > <td colspan="2" valign=top><Use rControl2:Place Header runat="server" /></td> <tr> <td width="563" valign=top style="padding-left:40px "><div align=left class=formtext sty style="padding-left:8px
"></div><br><UserCo ntrol3:Control runat="server" /></td> <td>2</td> </tr>
<TR> <td colspan=2>  ;</td> <td> </tr> </table> </form> </body> </html> "S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in message news:10******** *****@corp.supe rnews.com... Moe,
No, that looks good. It shouldn't make a difference that it's in a user control.
Are you adding the user control to the page dynamically?
-- Sincerely,
S. Justin Gengo, MCP Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order." Nietzsche "Moe Sizlak" <mo*@moe.com> wrote in message news:e%******** ********@TK2MSF TNGP09.phx.gbl. .. Hi Justin,
I have the listmenu on the page and I do make sure that the menu is selected before clicking the button, the load sud where I bind the list is in
the user control. Would this make a difference?
Moe
Sub Page_Load(byVal obj As Object, byVal e As EventArgs) If Not Page.IsPostBack Then lstS.DataSource = CommonFunctions .BindStates lstS.DataBind() lstS.Items.Inse rt(0, new ListItem("By State","0")) End If End Sub
"S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in
message news:10******** *****@corp.supe rnews.com... > Moe, > > First I am assuming that you aren't trying to repsponse.write the value > until after it's selected. You'll get the object reference error
right away > otherwise since no value has been selected yet. > > Second, you need to make certain that the code populating the list only > fires on page load. If not, it is resetting the list every time. Do this > with the following if then: > > If Not Page.IsPostBack Then > '---Populate list only once here > End If > > > -- > Sincerely, > > S. Justin Gengo, MCP > Web Developer / Programmer > > www.aboutfortunate.com > > "Out of chaos comes order." > Nietzsche > "Moe Sizlak" <mo*@moe.com> wrote in message > news:%2******** ********@tk2msf tngp13.phx.gbl. .. > > Hi There, > > > > I am trying to write the selected value of a listcontrol when a button is > > clicked and I keep getting the error "object not set to a
reference of an > > object". The libox itself is in a usercontrol and all i'm really needing > to > > do is get the selected value when the button is clicked on the
form. > > > > Can someone tell what I need to include in my page to get this working ? > > > > Moe <>< > > > > !-- response.write > > > > response.write (lstS.selectedI tem.tostring()) > > > > response.end > > > > > > !-- class function > > > > Public Class CommonFunctions > > Public Shared Function BindStates() as SqlDataReader > > > > Dim myConnection as New > >
SqlConnection(C onfigurationSet tings.AppSettin gs("connectionS tring")) > > Const strSQL as String = "SELECT LocationID,
Location AS > > Location " & _ > > "FROM tbLocation
ORDER BY > > Location" > > Dim myCommand as New SqlCommand(strS QL, myConnection) > > myConnection.Op en() > > Dim objDR as SqlDataReader > > objDR = myCommand.Execu teReader(Comman dBehavior.Close Connection) > > Return objDr > > End Function > > End Class > > > > !-- bind the contro > > > > lstS.DataSource = CommonFunctions .BindStates > > lstS.DataBind() > > lstS.Items.Inse rt(0, new ListItem("By State","0")) > > > > !- lisbox on page > > > > <asp:listbox id="lstS" runat="server" rows=1 > > DataTextField=" Location" DataValueField= "LocationID "/> > > > > > >
Moe,
Are you trying to response.write the value from the user control itself or
from the page the control is on?
If you are trying to write it from the page the control is on you can't
refer to it directly. You have to refer to it through the user control
itself.
You could do this two ways:
One would be to just response.write the value from the control itself using
the data list's OnSelectedValue Changed handler
The other would be to use FindControl on the main page to get a reference to
the user control object and then use that to refer to the datalist.
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Moe Sizlak" <mo*@moe.com> wrote in message
news:eD******** ******@TK2MSFTN GP11.phx.gbl... Hi Justin,
Any other ideas? have a forgotten to declare something in my page?
"Moe Sizlak" <mo*@moe.com> wrote in message news:uD******** ******@TK2MSFTN GP10.phx.gbl... Hi Justin,
The control I am using is "includes/_control_conten t.ascx" and I just include it in the main page. What else could it be?
Sean
<% @Import Namespace="Syst em.Data" %> <% @Import Namespace="Syst em.Data.SqlClie nt" %> <% @Import Namespace="Syst em.Web.UI.WebCo ntrols.DropDown List" %> <%@ Import Namespace="Syst em.Web.UI.WebCo ntrols.CheckBox " %> <%@ Register TagPrefix="User Control2" TagName="PlaceH eader" Src="includes/_placelistingsu ser_header.ascx " %> <%@ Register TagPrefix="User Control3" TagName="Contro l" Src="includes/_control_conten t.ascx" %> <%@ Register TagPrefix="User Control4" TagName="FormLi st" Src="includes/_formlist_conte nt.ascx" %> <link rel="stylesheet " type="text/css" href="> <script language="vb" runat="server"> </script>
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="distribut ion" content="global "> <meta name="revisit-after" content="14 days"> <meta name="ROBOTS" content="ALL">
<title>title</title> </head> <form enctype="multip art/form-data" runat="server"> <body topmargin="0" marginheight="0 " marginwidth="0" > <table width="100%" border="0" cellpadding="0" cellspacing="0" > <td colspan="2" valign=top><Use rControl2:Place Header runat="server" /></td> <tr> <td width="563" valign=top style="padding-left:40px "><div
align=left class=formtext sty style="padding-left:8px "></div><br><UserCo ntrol3:Control runat="server" /></td> <td>2</td> </tr>
<TR> <td colspan=2>  ;</td> <td> </tr> </table> </form> </body> </html> "S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in message news:10******** *****@corp.supe rnews.com... Moe,
No, that looks good. It shouldn't make a difference that it's in a
user control.
Are you adding the user control to the page dynamically?
-- Sincerely,
S. Justin Gengo, MCP Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order." Nietzsche "Moe Sizlak" <mo*@moe.com> wrote in message news:e%******** ********@TK2MSF TNGP09.phx.gbl. .. > Hi Justin, > > I have the listmenu on the page and I do make sure that the menu is selected > before clicking the button, the load sud where I bind the list is in the > user control. Would this make a difference? > > Moe > > Sub Page_Load(byVal obj As Object, byVal e As EventArgs) > If Not Page.IsPostBack Then > lstS.DataSource = CommonFunctions .BindStates > lstS.DataBind() > lstS.Items.Inse rt(0, new ListItem("By State","0")) > End If > End Sub > > > "S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in message > news:10******** *****@corp.supe rnews.com... > > Moe, > > > > First I am assuming that you aren't trying to repsponse.write the value > > until after it's selected. You'll get the object reference error right > away > > otherwise since no value has been selected yet. > > > > Second, you need to make certain that the code populating the list only > > fires on page load. If not, it is resetting the list every time.
Do this > > with the following if then: > > > > If Not Page.IsPostBack Then > > '---Populate list only once here > > End If > > > > > > -- > > Sincerely, > > > > S. Justin Gengo, MCP > > Web Developer / Programmer > > > > www.aboutfortunate.com > > > > "Out of chaos comes order." > > Nietzsche > > "Moe Sizlak" <mo*@moe.com> wrote in message > > news:%2******** ********@tk2msf tngp13.phx.gbl. .. > > > Hi There, > > > > > > I am trying to write the selected value of a listcontrol when a button > is > > > clicked and I keep getting the error "object not set to a reference of > an > > > object". The libox itself is in a usercontrol and all i'm really needing > > to > > > do is get the selected value when the button is clicked on the form. > > > > > > Can someone tell what I need to include in my page to get this
working ? > > > > > > Moe <>< > > > > > > !-- response.write > > > > > > response.write (lstS.selectedI tem.tostring()) > > > > > > response.end > > > > > > > > > !-- class function > > > > > > Public Class CommonFunctions > > > Public Shared Function BindStates() as SqlDataReader > > > > > > Dim myConnection as New > > > SqlConnection(C onfigurationSet tings.AppSettin gs("connectionS tring")) > > > Const strSQL as String = "SELECT LocationID, Location AS > > > Location " & _ > > > "FROM tbLocation ORDER BY > > > Location" > > > Dim myCommand as New SqlCommand(strS QL, myConnection) > > > myConnection.Op en() > > > Dim objDR as SqlDataReader > > > objDR = > myCommand.Execu teReader(Comman dBehavior.Close Connection) > > > Return objDr > > > End Function > > > End Class > > > > > > !-- bind the contro > > > > > > lstS.DataSource = CommonFunctions .BindStates > > > lstS.DataBind() > > > lstS.Items.Inse rt(0, new ListItem("By State","0")) > > > > > > !- lisbox on page > > > > > > <asp:listbox id="lstS" runat="server" rows=1 > > > DataTextField=" Location" DataValueField= "LocationID "/> > > > > > > > > > > > >
Hi Justin,
I am trying to use the response.write from the user control itself, I
managed to create a class in a code behind then reference the control in the
usercontrol page. The control displays correctly but when I try to catch the
value from the listbox it gives me the message "text is not a member of
string". I know that I'm almost there!!
Once I have the basic framework with this piece of code I will be able to
rollon from there.
Sean
"S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in message
news:10******** *****@corp.supe rnews.com... Moe,
Are you trying to response.write the value from the user control itself or from the page the control is on?
If you are trying to write it from the page the control is on you can't refer to it directly. You have to refer to it through the user control itself.
You could do this two ways:
One would be to just response.write the value from the control itself
using the data list's OnSelectedValue Changed handler
The other would be to use FindControl on the main page to get a reference
to the user control object and then use that to refer to the datalist.
-- Sincerely,
S. Justin Gengo, MCP Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order." Nietzsche "Moe Sizlak" <mo*@moe.com> wrote in message news:eD******** ******@TK2MSFTN GP11.phx.gbl... Hi Justin,
Any other ideas? have a forgotten to declare something in my page?
"Moe Sizlak" <mo*@moe.com> wrote in message news:uD******** ******@TK2MSFTN GP10.phx.gbl... Hi Justin,
The control I am using is "includes/_control_conten t.ascx" and I just include it in the main page. What else could it be?
Sean
<% @Import Namespace="Syst em.Data" %> <% @Import Namespace="Syst em.Data.SqlClie nt" %> <% @Import Namespace="Syst em.Web.UI.WebCo ntrols.DropDown List" %> <%@ Import Namespace="Syst em.Web.UI.WebCo ntrols.CheckBox " %> <%@ Register TagPrefix="User Control2" TagName="PlaceH eader" Src="includes/_placelistingsu ser_header.ascx " %> <%@ Register TagPrefix="User Control3" TagName="Contro l" Src="includes/_control_conten t.ascx" %> <%@ Register TagPrefix="User Control4" TagName="FormLi st" Src="includes/_formlist_conte nt.ascx" %> <link rel="stylesheet " type="text/css" href="> <script language="vb" runat="server"> </script>
<html> <head> <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1"> <meta name="distribut ion" content="global "> <meta name="revisit-after" content="14 days"> <meta name="ROBOTS" content="ALL">
<title>title</title> </head> <form enctype="multip art/form-data" runat="server"> <body topmargin="0" marginheight="0 " marginwidth="0" > <table width="100%" border="0" cellpadding="0" cellspacing="0" > <td colspan="2" valign=top><Use rControl2:Place Header
runat="server" /></td> <tr> <td width="563" valign=top style="padding-left:40px "><div align=left class=formtext sty style="padding-left:8px "></div><br><UserCo ntrol3:Control runat="server" /></td> <td>2</td> </tr>
<TR> <td colspan=2>  ;</td> <td> </tr> </table> </form> </body> </html> "S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in
message news:10******** *****@corp.supe rnews.com... > Moe, > > No, that looks good. It shouldn't make a difference that it's in a user > control. > > Are you adding the user control to the page dynamically? > > -- > Sincerely, > > S. Justin Gengo, MCP > Web Developer / Programmer > > www.aboutfortunate.com > > "Out of chaos comes order." > Nietzsche > "Moe Sizlak" <mo*@moe.com> wrote in message > news:e%******** ********@TK2MSF TNGP09.phx.gbl. .. > > Hi Justin, > > > > I have the listmenu on the page and I do make sure that the menu
is > selected > > before clicking the button, the load sud where I bind the list is
in the > > user control. Would this make a difference? > > > > Moe > > > > Sub Page_Load(byVal obj As Object, byVal e As EventArgs) > > If Not Page.IsPostBack Then > > lstS.DataSource = CommonFunctions .BindStates > > lstS.DataBind() > > lstS.Items.Inse rt(0, new ListItem("By State","0")) > > End If > > End Sub > > > > > > "S. Justin Gengo" <sjgengo@aboutf ortunate[no-spam].com> wrote in message > > news:10******** *****@corp.supe rnews.com... > > > Moe, > > > > > > First I am assuming that you aren't trying to repsponse.write
the value > > > until after it's selected. You'll get the object reference error right > > away > > > otherwise since no value has been selected yet. > > > > > > Second, you need to make certain that the code populating the
list only > > > fires on page load. If not, it is resetting the list every time.
Do this > > > with the following if then: > > > > > > If Not Page.IsPostBack Then > > > '---Populate list only once here > > > End If > > > > > > > > > -- > > > Sincerely, > > > > > > S. Justin Gengo, MCP > > > Web Developer / Programmer > > > > > > www.aboutfortunate.com > > > > > > "Out of chaos comes order." > > > Nietzsche > > > "Moe Sizlak" <mo*@moe.com> wrote in message > > > news:%2******** ********@tk2msf tngp13.phx.gbl. .. > > > > Hi There, > > > > > > > > I am trying to write the selected value of a listcontrol when
a button > > is > > > > clicked and I keep getting the error "object not set to a reference of > > an > > > > object". The libox itself is in a usercontrol and all i'm
really > needing > > > to > > > > do is get the selected value when the button is clicked on the form. > > > > > > > > Can someone tell what I need to include in my page to get this working > ? > > > > > > > > Moe <>< > > > > > > > > !-- response.write > > > > > > > > response.write (lstS.selectedI tem.tostring()) > > > > > > > > response.end > > > > > > > > > > > > !-- class function > > > > > > > > Public Class CommonFunctions > > > > Public Shared Function BindStates() as SqlDataReader > > > > > > > > Dim myConnection as New > > > > SqlConnection(C onfigurationSet tings.AppSettin gs("connectionS tring")) > > > > Const strSQL as String = "SELECT LocationID, Location > AS > > > > Location " & _ > > > > "FROM tbLocation ORDER BY > > > > Location" > > > > Dim myCommand as New SqlCommand(strS QL,
myConnection) > > > > myConnection.Op en() > > > > Dim objDR as SqlDataReader > > > > objDR = > > myCommand.Execu teReader(Comman dBehavior.Close Connection) > > > > Return objDr > > > > End Function > > > > End Class > > > > > > > > !-- bind the contro > > > > > > > > lstS.DataSource = CommonFunctions .BindStates > > > > lstS.DataBind() > > > > lstS.Items.Inse rt(0, new ListItem("By State","0")) > > > > > > > > !- lisbox on page > > > > > > > > <asp:listbox id="lstS" runat="server" rows=1 > > > > DataTextField=" Location" DataValueField= "LocationID "/> > > > > > > > > > > > > > > > > > > > >
Hi.
Did anyone manage to find the solution to this problem?
I'm having a similar issue with populating a drop-down list menu from
a SQLDataReader.
Here is my function:-
Function SelectOptions(B yVal queryString) As
System.Data.Sql Client.SqlDataR eader
' Application("Co nnectionString" ) is set in our global.asax file
Dim sqlConnection As System.Data.Sql Client.SqlConne ction = New
System.Data.Sql Client.SqlConne ction(Applicati on("ConnectionS tring"))
Dim sqlCommand As System.Data.Sql Client.SqlComma nd = New
System.Data.Sql Client.SqlComma nd(queryString, sqlConnection)
sqlConnection.O pen()
Dim dataReader As System.Data.Sql Client.SqlDataR eader =
sqlCommand.Exec uteReader(Syste m.Data.CommandB ehavior.CloseCo nnection)
Return dataReader
End Function
If I call this function directly in my aspx page it works fine, no
problem.
However, if i attempt to call it via my own custom web user control
ascx page, it causes a "Object reference not set to an instance of an
object." error.
Here is my non-working code:-
Dim func As New CommonFunctions
dropdownlist.Da taSource = func.SelectOpti ons("SELECT colname FROM
table")
dropdownlist.Da taBind()
Any help is much appreciated.
Thanks in advance
Dan Williams.
It appears that my web user control didn't like my
Application("Co nnectionString" ) setting.
As soon as i referenced it using
System.Web.Http Context.Current .Application("c onnectionString "), it
worked straight away, no problem.
Cheers
Dan. da**********@ne wcross-nursing.com (Dan Williams) wrote in message news:<2e******* *************** **@posting.goog le.com>... Hi.
Did anyone manage to find the solution to this problem?
I'm having a similar issue with populating a drop-down list menu from a SQLDataReader.
Here is my function:-
Function SelectOptions(B yVal queryString) As System.Data.Sql Client.SqlDataR eader ' Application("Co nnectionString" ) is set in our global.asax file
Dim sqlConnection As System.Data.Sql Client.SqlConne ction = New System.Data.Sql Client.SqlConne ction(Applicati on("ConnectionS tring"))
Dim sqlCommand As System.Data.Sql Client.SqlComma nd = New System.Data.Sql Client.SqlComma nd(queryString, sqlConnection)
sqlConnection.O pen() Dim dataReader As System.Data.Sql Client.SqlDataR eader = sqlCommand.Exec uteReader(Syste m.Data.CommandB ehavior.CloseCo nnection)
Return dataReader End Function
If I call this function directly in my aspx page it works fine, no problem.
However, if i attempt to call it via my own custom web user control ascx page, it causes a "Object reference not set to an instance of an object." error.
Here is my non-working code:-
Dim func As New CommonFunctions dropdownlist.Da taSource = func.SelectOpti ons("SELECT colname FROM table") dropdownlist.Da taBind()
Any help is much appreciated.
Thanks in advance
Dan Williams. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Pkpatel |
last post by:
Hi,
I keep getting this error every time I try to load
crystalreportviewer on a webform with a dataset.
Here is the error:
--------------------------------------------------------
Server Error in '/Cr_Dataset' Application.
-----------------------------------------------------------
---------------------
|
by: kon george |
last post by:
Can somebody assist. I build this code on a dev laptop and copied across
the
entire code to a Windows 2003 server with 1.1 framework. It is basic
ASP.NE
T that uses web service for SQL Server 2000 DB access.
The code works fine on my dev laptop, just not on the non dev machine.
Here is the full error page:
|
by: Brad Coble |
last post by:
I have an activex control that is used in an old app originally written in
VB6. It works good. I updated the VB6 app to VB.net. Got it working, sort
of.
The activex control uses withevents and fires an event when there is
incoming message traffic. I need to capture that data. The event fires
sometimes. I know it should be firing more often because i run the vb6 app
and watch the traffic.
When I look at the debuger output I see a lot...
|
by: TS |
last post by:
Say i have a class car with properties: Color, Make, Model, Year, DriverID
And a Driver class with properties: DriverID, Name
The driverID PRIVATE property is the id of the driver from say a driver
table (t_driver). This has a PUBLIC property accessor called Driver
My understanding of OO using the composition model is that when you want to
load up a car class, you would access the DB to get Color, make, Model,
Year, DriverID and load...
|
by: Michael Slattery |
last post by:
Hello,
I see quite a few questions, but no valid responses to the question...
How do I store an ArrayList of items in a Properties file via the GUI?
I am able to select the System.Collections.ArrayList type, but I'm unable to
determine what to type into the Value feild for a default setting so the
property will not be null at runtime...
| |
by: docschnipp |
last post by:
Hi,
I have a bunch of object derived from the same base class. They all share
the same constructor with some parameters. Now, instead of using a large
switch() statement where I call every single Object by itself, I'd like to
assign a reference to the class type and call it later without knowing the
derived type.
Example:
|
by: Philipp Reif |
last post by:
Hi all,
I've got a little hole in my head concerning references. Here's what
I'm trying to do: I'm calling a function, passing the reference of a
business object for editing. The function clones the object, calls an
editor dialog to let the user edit the object, and then - depending on
the DialogResult - assigns either the clone/backup copy or the modified
object itself to the reference. Maybe I'm thinking too much in pointer
references...
|
by: giddy |
last post by:
ok i have a datagridview in my app and i have a function defined like
so:
public void FillColumns(ref DataGridView theDGV)
when i call it ... like this :
FillColumns(ref dataGridView2);
i get : Object reference not set to an instance of an object.
|
by: Cirene |
last post by:
I just installed VS.NET 2008 w/SP1 and the MySQL Connector 5.2. Does the
DataSet feature work with MySQL? I created a new dataset, DataSet1.xsd and
tried to add a TableAdapter. In the TableAdapter Configuration Wizard when I
try to use the Query Builder I get the error "Object Reference Not Set To An
Instance Of The Object". Any idea why? In fact, I can't even drag the table
from the Server Explorer to the DataSet1.xsd interface. I get...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |