I am passing a value from an aspx to an ascx like this. It is inside a gridview.
----------------------------------------------
<prefix1:name1 TestData='<%#eval("demid")%>' ID="ctrlTester1" runat="server" />
----------------------------------------------
At the top of the ascx is this
----------------------------------------------
Public x As Integer
Public Property testdata() As integer
Get
Return x
End Get
Set(ByVal value As integer)
x=value
Label1.Text = x 'LABEL1 SHOWS THE RIGHT VALUE
End Set
End Property
-----------------------------------------------
I am trying to use x in a query like this. It runs when the page loads.
-----------------------------------------------
Dim connection1 As SqlConnection = New SqlConnection()
connection1.Open()
Dim q As String = "select * from dems where demid=" & x.ToString()
Response.Write(q) ' ALWAYS HAS WHERE DEMID=0 HERE
Dim command1 As SqlCommand = New SqlCommand(q, connection1)
Dim reader1 As SqlDataReader = command1.ExecuteReader()
-----------------------------------------------
q keeps displaying as 'select * from dems where demid=0' but should not.
Demid is never 0. No rows are found.
The right value of x gets printed to a label so the value of x is there.
How do I get x to be the value of demid in the query?
----------------------------------------------
<prefix1:name1 TestData='<%#eval("demid")%>' ID="ctrlTester1" runat="server" />
----------------------------------------------
At the top of the ascx is this
----------------------------------------------
Public x As Integer
Public Property testdata() As integer
Get
Return x
End Get
Set(ByVal value As integer)
x=value
Label1.Text = x 'LABEL1 SHOWS THE RIGHT VALUE
End Set
End Property
-----------------------------------------------
I am trying to use x in a query like this. It runs when the page loads.
-----------------------------------------------
Dim connection1 As SqlConnection = New SqlConnection()
connection1.Open()
Dim q As String = "select * from dems where demid=" & x.ToString()
Response.Write(q) ' ALWAYS HAS WHERE DEMID=0 HERE
Dim command1 As SqlCommand = New SqlCommand(q, connection1)
Dim reader1 As SqlDataReader = command1.ExecuteReader()
-----------------------------------------------
q keeps displaying as 'select * from dems where demid=0' but should not.
Demid is never 0. No rows are found.
The right value of x gets printed to a label so the value of x is there.
How do I get x to be the value of demid in the query?