1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Problems getting correct data in ASP.

Discussion in 'C#' started by businessman332211, Aug 19, 2009.

  1. #1
    This is driving me crazy. I am really good at PHP but only mediocre at ASP. I have been running around with these 15-20 lines of code for a few days and it's driving me insane.
    
    <%@ Control Language="vb" %>
    <script runat="server">
        Public cmsID As String
        Public subContent As String
        Public content As String
        Public myLink As String
        Public cPage As Integer = 0
        Public headimage As String
    
        Dim s As New S
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
            AddStateOptions(stateFilter)
            stateFilter.AutoPostBack = True
            Dim Item As ListItem = New ListItem()
            With ind
                .Items.Add(Item)
                .AppendDataBoundItems = True
                .AutoPostBack = True
                .DataSource = FillRecs("select title,id from categorytbl order by title")
                .DataTextField = "title"
                .DataValueField = "id"
                .DataBind()
            End With
            
    	dim insertsql, stValue
    	stValue = stateFilter.SelectedValue
    
    	if stateFilter.SelectedValue <> "AA" then
    		insertsql = "and cpvalue='" & stValue & "'"
    	else
    		insertsql = "and cpvalue <> ''"
    	end if
    
    	Dim r As New Repeater
            With r
                .DataSource = FillRecs("Select * from account where businessname <> '' AND businessname is not null and id in (select uid from contentvalue where cpid=4 " & insertsql & ")")
                .HeaderTemplate = New BrowseTemplate(ListItemType.Header)
                .ItemTemplate = New BrowseTemplate(ListItemType.Item)
                .FooterTemplate = New BrowseTemplate(ListItemType.Footer)
                .DataBind()
            End With
            gen.Controls.Add(r)
            pgtitle.Controls.Add(AddLit(tag("h2", stateFilter.SelectedItem.Text & " Members")))
        End Sub
        
        Sub checkselection(ByVal sender As Object, ByVal e As System.EventArgs)
            dim insertsql, stValue
    	stValue = stateFilter.SelectedValue
    
    	if stateFilter.SelectedValue <> "AA" then
    		insertsql = "and cpvalue='" & stValue & "'"
    	else
    		insertsql = "and cpvalue <> ''"
    	end if
    
    	Dim r As New Repeater
            With r
                .DataSource = FillRecs("Select * from account where businessname <> '' AND businessname is not null and id in (select uid from contentvalue where cpid=4 " & insertsql & ")")
                .HeaderTemplate = New BrowseTemplate(ListItemType.Header)
                .ItemTemplate = New BrowseTemplate(ListItemType.Item)
                .FooterTemplate = New BrowseTemplate(ListItemType.Footer)
                .DataBind()
            End With
            gen.Controls.Add(r)
            pgtitle.Controls.Add(AddLit(tag("h2", stateFilter.SelectedItem.Text & " Members")))
        End Sub
            
    </script>
    <form runat=server>
    <div style="background:whitesmoke;width:100%">
    By State: <asp:DropDownList OnSelectedIndexChanged="checkselection" ID="stateFilter" runat="server" />
    
    By Industry: <asp:DropDownList OnSelectedIndexChanged="checkselection" ID="ind" runat="server" />
    </div></form>
    <asp:PlaceHolder ID=pgtitle runat=server />
    
      
    <asp:PlaceHolder ID="gen" runat="server" />
    
    Code (markup):
    This is the code for the browse page on my clients site. I basically need:
    1) When they come to the browse page it automatically starts off showing all results.
    2) When they pick a state from the drop down it filters based on that state.
    3) It sorts by Package Type

    Right now number 2 is working. I have tried rewriting this almost a hundred times to get it to do the first item.
    I have tried modifying the queries and everything..I have even tested them in Mssql...does anyone see any issues here related to why it might not be working..
    This was someone else's code that didn't finish what they were requested to finish.
     
    businessman332211, Aug 19, 2009 IP
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Hi.. is the event OnSelectedIndexChanged firing? I did something similar once and had to use javascript to get it to work properly. I don't have time right now but will help you later if you are still experiencing issues. What exactly is it that isn't happening.
    Oh and what is the line 'Dim s As New s' ??? Unless it is used somewhere else I don't think that should be there.
     
    camjohnson95, Aug 21, 2009 IP