Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0trouble with using user supplied variable to query tabletrouble with using user supplied variable to query table
Previous
 
Next
New Post
2/12/2006 12:38 PM
 
I'm new to dotnetnuke so please excuse the n00bness...

I'm writing a module that basically asks for a zip code and then queries a table for all records with that zip code.  I display 3 of the columns of these records in a gridview.

The form basically has a text box and a button and the gridview.  The user enters the zipcode into the textbox, hits submit, and populates a variable with their zip code as a string.  I have checked, and know that the variable is being populated correctly.

My problem is, however, that when I declare my variable(userZip) and use it in my stored procedure, my stored procedure doesnt know what the hell i'm talking about.  It's like the variable value is not getting to the stored procedure.  

I know the stored procedure is working on a basic level, because when I actually enter a hard zip code in single quotes inside the actual stored procedure, it pulls up all the records automatically in that particular zip code when I pull up the page.

So I'm thinking that either
A. I'm not passing the variable correctly to the stored procedure so it can use it to filter the records.
B. Because the gridview is being shown immediately upon page load, there is no value for the variable yet since the user hasn't had the chance to enter one.


maybe a better way to do this would be to not show the gridview until the users clicks submit?  How would I do this?


Here is the frontcode (viewmodulename.ascx):
<%@ Control Language="VB" Inherits="YourCompany.Modules.NNQHoods.ViewNNQHoods" CodeFile="ViewNNQHoods.ascx.vb"
AutoEventWireup="true" %>
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>
<asp:ObjectDataSource ID="ObjectDataSource_Tasks" runat="server" DataObjectTypeName="YourCompany.Modules.NNQHoods.NNQHoodsInfo"
SelectMethod="NNQHoods_GetAll" TypeName="YourCompany.Modules.NNQHoods.NNQHoodsController"
UpdateMethod="NNQHoods_Update" OnInit="Page_Load">
<SelectParameters>
<asp:Parameter DefaultValue="00" Name="ModuleId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<br />

<div><center>
<asp:Label ID="EnterZip" runat="server" Text="Enter Your Zip Code:"></asp:Label>
<asp:TextBox ID="txtZip" runat="server" Width="60px"></asp:TextBox>
<br />
<asp:Button ID="btnZip" runat="server" Text="Search" />
    <br />
    <br />
</center></div>

<asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource_Tasks"
AutoGenerateColumns="False" AllowPaging="True" HorizontalAlign="Center">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Neighborhood" SortExpression="Name" />
<asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
<asp:BoundField DataField="Zip" HeaderText="Zip" SortExpression="Zip" />
</Columns>
<EmptyDataTemplate>
There are no entries.
</EmptyDataTemplate>
</asp:GridView>
<br />
<center>
<dnn:Label ID="lblAddMessage" runat="server" ControlName="lblAddMessage" Suffix=":">
</dnn:Label>
</center>
<br />
<asp:FormView ID="FormView1" runat="server" DataSourceID="ObjectDataSource_Tasks" DefaultMode="Insert" HorizontalAlign="Center">
<InsertItemTemplate>

<br />
&nbsp;
</InsertItemTemplate>
</asp:FormView>


Here is the back (viewmodulename.ascx.vb):

Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.Entities.Modules
Namespace YourCompany.Modules.NNQHoods
    Partial Class ViewNNQHoods
        Inherits Entities.Modules.PortalModuleBase
        Implements Entities.Modules.IActionable
        Public ReadOnly Property ModuleActions() As Entities.Modules.Actions.ModuleActionCollection Implements Entities.Modules.IActionable.ModuleActions
            Get
                Dim Actions As New Entities.Modules.Actions.ModuleActionCollection
                Actions.Add(GetNextActionID, Localization.GetString(Entities.Modules.Actions.ModuleActionType.EditContent, LocalResourceFile), Entities.Modules.Actions.ModuleActionType.EditContent, "", "", EditUrl(), False, Security.SecurityAccessLevel.Edit, True, False)
                Return Actions
            End Get
        End Property

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            Try
                Dim objModules As ModuleController = New ModuleController
                If Not Page.IsPostBack Then
                    If (Not (CType(Settings("showform"), String)) Is Nothing) Then
                        If (CType(Settings("showform"), String) = "No") Then
                            ' Do not allow messages to be added
                            FormView1.Visible = False
                            lblAddMessage.Visible = False
                        End If
                    End If
                Else
                    Me.GridView1.DataBind()
                End If
            Catch ex As Exception
                Exceptions.ProcessModuleLoadException(Me, ex)
            End Try
        End Sub


        Protected Sub btnZip_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnZip.Click
            Dim userZip As String
            userZip = txtZip.Text
            EnterZip.Text = userZip
        End Sub
    End Class
End Namespace

 
New Post
2/14/2006 5:10 PM
 
Are you sure the querystring variable is being processed correctly? If you are using friendly URLs, then you have to add code to the SiteUrls.config file so it knows how to handle the querystring.

Michael Flanakin | Microsoft Consulting Services
www.michaelflanakin.com
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0trouble with using user supplied variable to query tabletrouble with using user supplied variable to query table


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out