Forum Moderators: open

Message Too Old, No Replies

Newbie Question on form variables

Simple question

         

Hamishrock

8:39 am on Apr 10, 2008 (gmt 0)

10+ Year Member



I am new to asp, and I am using .net 2 to attempt a site.

My first simple problem using code behind pages is that I can not find my form variables. I am using

Partial Class CCTDetail
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Label1.Text = Request.Form("CCTNo")
End Sub

End Class

to try and output the form variable CCTNO, but nothing is appearing in the label area.

I am also using

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NetworkResilienceConnectionString %>"
SelectCommand="SELECT [id], [nodes] FROM [TBL_NR_CCTS] WHERE ([cctno] = @CCTNo)">
<SelectParameters>
<asp:QueryStringParameter Name="CCTNo" Type="Int32" QueryStringField="CCTNo" />
</SelectParameters>
</asp:SqlDataSource>

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="nodes" HeaderText="nodes" SortExpression="nodes" />
</Columns>
</asp:GridView>

to do a simple query but that is not working either.

How should I referance the variable?

[edited by: Hamishrock at 8:40 am (utc) on April 10, 2008]

Hamishrock

12:22 pm on Apr 10, 2008 (gmt 0)

10+ Year Member



A bit more info is that I am using
<asp:TextBox ID="cct" runat="server" Text="1"></asp:TextBox>

in the entry page to call the output page, and changing to a normal html input box

<input type="text" name="cct" />

allows me to set the select parameter by

<asp:FormParameter Name="cct" Type="int32" FormField="cct" />.

But how do I set my select parameter if I use the <asp:TextBox as the entry box?