Form Postback not altering query

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I regularly code in Classic ASP but rarely in asp.net and so Im probably missing a basic step here. The Postback alters Message the but not the Query. Here is my code:
<%@ Page MasterPageFile="CairnAgency.master" AutoEventWireup="false" Title="The Cairn Agency Home Page" %><br/>
<script runat="server <br/>
Sub SubmitBtn_Click(ByVal sender As Object, ByVal e As EventArgs)<br/>
Message.Text = "Filter Applied - "<br/>
If ClientTypeDd1.Text <> "" Then<br/>
Message.Text = Message.Text & ClientTypeDd1.Text<br/>
ClientTypeDd1.DataBind()<br/>
End If<br/>
If AgeRangeDd1.Text <> "" Then<br/>
Message.Text = Message.Text & " aged " & AgeRangeDd1.Text<br/>
AgeRangeDd1.DataBind()<br/>
End If<br/>
If AgeRangeDd2.Text <> "" Then<br/>
Message.Text = Message.Text & "-" & AgeRangeDd2.Text & " years"<br/>
AgeRangeDd2.DataBind()<br/>
End If<br/>
If HeightDdl.Text <> "" Then<br/>
Message.Text = Message.Text & " and of height " & HeightDdl.Text<br/>
HeightDdl.DataBind()<br/>
End If<br/>
If HeightDd2.Text <> "" Then<br/>
Message.Text = Message.Text & "-" & HeightDd2.Text & "cm"<br/>
HeightDd2.DataBind()<br/>
End If<br/>
If BuildDdl.Text <> "" Then<br/>
Message.Text = Message.Text & " of " & BuildDdl.Text & " build"<br/>
BuildDdl.DataBind()<br/>
End If<br/>
If HaircolourDdl.Text <> "" Then<br/>
Message.Text = Message.Text & " with " & HaircolourDdl.Text & " coloured hair"<br/>
HaircolourDdl.DataBind()<br/>
End If<br/>
If EyecolourDdl.Text <> "" Then<br/>
Message.Text = Message.Text & " with " & EyecolourDdl.Text & " coloured eyes"<br/>
EyecolourDdl.DataBind()<br/>
End If<br/>
If EthnicityDd1.Text <> "" Then<br/>
Message.Text = Message.Text & " of " & EthnicityDd1.Text & " ethnic origin"<br/>
EthnicityDd1.DataBind()<br/>
End If<br/>
End Sub<br/>
</script><br/>
<asp:Content id="headertext" runat="server" contentplaceholderid="headtxt <br/>
<h1>View the galllery of talent we have available</h1><br/>
<h3><asp:label id="Message" Text="Use these options to Filter Your Search Critera" runat="server"/></h3><br/>
<div class="selectionarea <br/>
<asp:Label ID="ClientType" Text="Clyent Type:" runat="server" /><br /><br/>
<asp:DropDownList ID="ClientTypeDd1" runat="server" DataSourceID="ClientTypeSelect" DataTextField="Client_Type" DataValueField="Client_Type" ><br/>
<asp:ListItem>Please Select</asp:ListItem><br/>
</asp:DropDownList><br/>
<br /><br/>
<asp:Label ID="LowerAge" Text="Lower Age:" runat="server" /><br /><br/>
<asp:DropDownList ID="AgeRangeDd1" runat="server" DataSourceID="ClientAgeSelect" DataTextField="Ages" DataValueField="Ages" /><br /><br/>
<asp:Label ID="UpperAge" Text="Upper Age:" runat="server" /><br /><br/>
<asp:DropDownList ID="AgeRangeDd2" runat="server" DataSourceID="ClientAgeSelectDesc" DataTextField="Ages" DataValueField="Ages" AutoPostBack="True" /><br/>
<br/>
<div class="selectionarea <br/>
<asp:Label ID="LowerHeight" Text="Lower Height:" runat="server" /><br /><br/>
<asp:DropDownList ID="HeightDdl" runat="server" DataSourceID="ClientHeightSelect" DataTextField="Height" DataValueField="Height" /><br /><br/>
<asp:Label ID="UpperHeight" Text="Upper Height:" runat="server" /><br /><br/>
<asp:DropDownList ID="HeightDd2" runat="server" DataSourceID="ClientHeightSelectDesc" DataTextField="Height" DataValueField="Height" /><br /><br/>
<asp:Label ID="Build" Text="Build:" runat="server" /><br /><br/>
<asp:DropDownList ID="BuildDdl" runat="server" DataSourceID="ClientBuildSelect" DataTextField="Build" DataValueField="Build" /><br/>
<br/>
<div class="selectionarea <br/>
<asp:Label ID="Hair" Text="Hair Colour:" runat="server" /><br /><br/>
<asp:DropDownList ID="HaircolourDdl" runat="server" DataSourceID="ClientHairSelect" DataTextField="Hair_Colour" DataValueField="Hair_Colour" /><br /><br/>
<asp:Label ID="Eyes" Text="Eye Colour:" runat="server" /><br /><br/>
<asp:DropDownList ID="EyecolourDdl" runat="server" DataSourceID="ClientEyesSelect" DataTextField="Eye_Colour" DataValueField="Eye_Colour" /><br /><br/>
<asp:Label ID="Ethnicity" Text="Ethnic Origin:" runat="server" /><br /><br/>
<asp:DropDownList ID="EthnicityDd1" runat="server" DataSourceID="ClientEthnicitySelect" DataTextField="Ethnic_Origin" DataValueField="Ethnic_Origin" /><br/>
<br/>
<div class="selectionarea <br/>
<asp:Label ID="Audio" Text="Voice Demos:" runat="server" /><br /><br/>
<asp:DropDownList ID="AudioDdl" runat="server <br/>
<asp:ListItem Text="All" Value="all </asp:ListItem><br/>
<asp:ListItem Text="Yes" Value="yes </asp:ListItem><br/>
<asp:ListItem Text="No" Value="no </asp:ListItem><br/>
</asp:DropDownList><br /><br/>
<asp:Label ID="Video" Text="Show Reels:" runat="server" /><br /><br/>
<asp:DropDownList ID="VideoDdl" runat="server <br/>
<asp:ListItem Text="All" Value="all </asp:ListItem><br/>
<asp:ListItem Text="Yes" Value="yes </asp:ListItem><br/>
<asp:ListItem Text="No" Value="no </asp:ListItem><br/>
</asp:DropDownList><br/>
<br /><br /><br/>
<asp:Button ID="filter" runat="server" Text=" Apply Filter " Width="140px"
<br/>
PostBackUrl="~/NewVersion/clientlist.aspx"
<br/>
ToolTip="Click to filter client records" onclick="SubmitBtn_Click" /><br /><br/>
<br/>
<asp:SqlDataSource ID="ClientTypeSelect" runat="server" <br/>
ConnectionString="<%$ ConnectionStrings:CAconnectionString %>"
<br/>
SelectCommand="SELECT Client_Type FROM [qryClientTypeList]"
<br/>
ProviderName="System.Data.SqlClient <br/>
</asp:SqlDataSource><br/>
<asp:SqlDataSource ID="ClientAgeSelect" runat="server" <br/>
ConnectionString="<%$ ConnectionStrings:CAconnectionString %>"
<br/>
SelectCommand="SELECT CAST(CurrentAge as int) AS Ages FROM [qryClientAgeList]"
<br/>
ProviderName="System.Data.SqlClient <br/>
</asp:SqlDataSource><br/>
<asp:SqlDataSource ID="ClientAgeSelectDesc" runat="server"
<br/>
ConnectionString="<%$ ConnectionStrings:CAconnectionString %>"
<br/>
SelectCommand="SELECT CAST(CurrentAge as int) AS Ages FROM [qryClientAgeList] ORDER BY CurrentAge DESC"
<br/>
ProviderName="System.Data.SqlClient <br/>
</asp:SqlDataSource><br/>
<asp:SqlDataSource ID="ClientBuildSelect" runat="server" <br/>
ConnectionString="<%$ ConnectionStrings:CAconnectionString %>"
<br/>
SelectCommand="SELECT Build FROM [qryClientBuildList] <br/>
</asp:SqlDataSource><br/>
<asp:SqlDataSource ID="ClientHeightSelect" runat="server" <br/>
ConnectionString="<%$ ConnectionStrings:CAconnectionString %>"
<br/>
SelectCommand="SELECT Height FROM [qryClientHeightList] <br/>
</asp:SqlDataSource><br/>
<asp:SqlDataSource ID="ClientHeightSelectDesc" runat="server"
<br/>
ConnectionString="<%$ ConnectionStrings:CAconnectionString %>"
<br/>
SelectCommand="SELECT Height FROM [qryClientHeightList] ORDER by Height Desc <br/>
</asp:SqlDataSource><br/>
<asp:SqlDataSource ID="ClientHairSelect" runat="server" <br/>
ConnectionString="<%$ ConnectionStrings:CAconnectionString %>"
<br/>
SelectCommand="SELECT Hair_Colour FROM [qryClientHairList] <br/>
</asp:SqlDataSource><br/>
<asp:SqlDataSource ID="ClientEyesSelect" runat="server" <br/>
ConnectionString="<%$ ConnectionStrings:CAconnectionString %>"
<br/>
SelectCommand="SELECT Eye_Colour FROM [qryClientEyesList] <br/>
</asp:SqlDataSource><br /><br/>
<asp:SqlDataSource ID="ClientEthnicitySelect" runat="server"
<br/>
ConnectionString="<%$ ConnectionStrings:CAconnectionString %>"
<br/>
SelectCommand="SELECT [Ethnic_Origin] FROM [QryClientEthnicityList] <br/>
</asp:SqlDataSource><br/>
</asp:Content><br/>
<asp:Content id="bodyContent" runat="server" contentplaceholderid="bodytxt <br/>
<div class="light <br/>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ClientList"
<br/>
DataMember="DefaultView <br/>
<headertemplate><br/>
<ul class="clientrepeater <br/>
</headertemplate><br/>
<itemtemplate><br/>
<br/>
<asp:hyperlink ID="Hyperlink1" NavigateUrl=viewprofile.aspx?id=<%# Eval("Online_ClientID")%> CssClass=center runat=server><br/>
<asp:image id="ClientImage"<br/>
imageurl=<%# "/files/images/" & Eval("Image_URL") %> CssClass=barepic<br/>
alternatetext=<%# Eval("Full_Name") %>
<br/>
runat="server"/><br/>
<br /><br/>
<%# Eval("Full_Name")%><br/>
<br /><br/>
<%# Eval("Client_Type")%></asp:hyperlink>
<br/>
<br/>
</itemtemplate><br/>
<footertemplate><br/>
<br/>
</footertemplate><br/>
</asp:Repeater><br/>
<br/>
<asp:SqlDataSource ID="ClientList" runat="server" <br/>
ConnectionString="<%$ ConnectionStrings:CAconnectionString %>"
<br/>
SelectCommand="SELECT [Online_ClientID], [Full_Name], [Client_Type], [Image_URL], [Image_Heading] FROM [qryClientWebList] WHERE (([IsDefaultImage] = @IsDefaultImage) AND ([Client_Type] LIKE @Client_Type) AND
([CurrentAge] &gt;= @CurrentAge) AND ([CurrentAge] &lt;= @CurrentAge2) AND ([Height] &gt;= @Height) AND ([Height] &lt;= @Height2) AND ([Hair_Colour] LIKE @Hair_Colour) AND ([Eye_Colour] LIKE @Eye_Colour) AND ([Build] LIKE @Build) AND ([Ethnic_Origin]
LIKE @Ethnic_Origin)) <br/>
<SelectParameters><br/>
<asp:Parameter DefaultValue="true" Name="IsDefaultImage" Type="Boolean" /><br/>
<asp:FormParameter DefaultValue="%" FormField="ClientTypeDd1.Text" Name="Client_Type" Type="String" /><br/>
<asp:FormParameter FormField="AgeRangeDd1" DefaultValue="0" Name="CurrentAge" Type="Decimal" /><br/>
<asp:FormParameter FormField="AgeRangeDd2" DefaultValue="130" Name="CurrentAge2" Type="Decimal" /><br/>
<asp:FormParameter FormField="HeightDdl" DefaultValue="0" Name="Height" Type="Int32" /><br/>
<asp:FormParameter FormField="HeightDd2" DefaultValue="3000" Name="Height2" Type="Int32" /><br/>
<asp:FormParameter FormField="HaircolourDdl" DefaultValue="%" Name="Hair_Colour" Type="String" /><br/>
<asp:FormParameter FormField="EyecolourDdl" DefaultValue="%" Name="Eye_Colour" Type="String" /><br/>
<asp:FormParameter FormField="BuildDdl" DefaultValue="%" Name="Build" Type="String" /><br/>
<asp:FormParameter FormField="EthnicityDd1" DefaultValue="%" Name="Ethnic_Origin" Type="String" /><br/>
</SelectParameters><br/>
</asp:SqlDataSource><br/>
</asp:Content>
I want the queery in this to be updated using the form inputs on post back. Can you spot what is stopping that from happening?
<span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small <span style="color:#0000ff; font-size:small <hr class="sig Brian Watson

View the full article
 
Back
Top