navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Default Value "null" for Dropdown

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Expression Web Help >> Default Value "null" for Dropdown
Page: [1]
 
swoosh

 

Posts: 1434
Joined: 5/18/2002
From: Beaver Falls, PA
Status: offline

 
Default Value "null" for Dropdown - 5/14/2008 20:05:03   
Just want to give KUDO's to Roger and Jaybee for my previous post about the Image/Hyperlink Control that now works thanks to them.

On that same page I have a dropdown list that is populated from the town field in my database (only selecting unique values) so only each town is listed once. When a town is selected it Auto Post Back to itself and shows all of the results for the selection

When the page is initially loaded, all towns appear in the dropdown which is cool, but it shows all the properties of the town that is listed first by default.

How does one modify it so that it doesn't grab the first town in the list and show the results, is there a way to make it show a null default value at first?

< Message edited by swoosh -- 5/14/2008 20:20:46 >


_____________________________

Swoooosh
Just Do It!

rdouglass

 

Posts: 9167
From: Biddeford, ME USA
Status: offline

 
RE: Default Value "null" for Dropdown - 5/14/2008 22:43:50   
quote:

is there a way to make it show a null default value at first?


If its .NET, then sometimes just wrapping the call inside:

If IsPostBack Then
'use the dropdown select code
End IF

That should ignore anything inside upon initial entry to the page. Hope it helps.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to swoosh)
swoosh

 

Posts: 1434
Joined: 5/18/2002
From: Beaver Falls, PA
Status: offline

 
RE: Default Value "null" for Dropdown - 5/15/2008 9:40:09   
Thanks Roger, but how and where exactly, sorry for my ignorance but I'm still in the beginning stages of learning .NET.....here is my code below for the dropdown and source

<asp:DropDownList runat="server" id="DropDownList1" DataTextField="Town" DataSourceID="AccessDataSource1" DataValueField="Town" AutoPostBack="True" Width="134px" Height="16px">
</asp:DropDownList>
</div>

<asp:AccessDataSource runat="server" ID="AccessDataSource1" DataFile="fpdb/downtownproperties.mdb" SelectCommand="SELECT DISTINCT [Town] FROM [Properties]">
</asp:AccessDataSource>


_____________________________

Swoooosh
Just Do It!


(in reply to swoosh)
rdouglass

 

Posts: 9167
From: Biddeford, ME USA
Status: offline

 
RE: Default Value "null" for Dropdown - 5/15/2008 10:44:54   
Sorry, I re-read my post and it wasn't very clear.

That code doesn't wrap around the dropdown but rather the code that displays the list of towns. For instance, if you were using a daqtgrid to show the list, it might look something like this:

...
If IsPostBack Then
myDataGrid.Visible = True
Else
myDataGrid.Visible = False
End If
...

Does that make sense at all? We don't want to act on the dropdown but rather the area / datagrid /list / table / etc. that displays the data.

Eitehr that or you can set the default to somethign different for the display data.

It's a little tough to tell which without page code to look at but hopefully that'll help.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to swoosh)
swoosh

 

Posts: 1434
Joined: 5/18/2002
From: Beaver Falls, PA
Status: offline

 
RE: Default Value "null" for Dropdown - 5/15/2008 10:48:59   
I have posted the page code for the results............the best part about this is learning.........I actually understand what you typed and what it is doing.........but the part of where is my problem.

 									<asp:DataList runat="server" id="DataList1" DataKeyField="ID" DataSourceID="AccessDataSource2" Width="511px" Font-Size="Small">
										<ItemTemplate>
											<table style="width: 101%">
												<tr>
													<td style="width: 144px" valign="top" class="style7">
													<asp:Image runat="server" id="Image1" ImageUrl='<%# Eval("Picture", "~/property_images/{0}") %>' Height="94px" Width="125px" class="style34" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" />
													</td>
													<td valign="top" class="style9" style="width: 170px">
													<asp:Label Text='<%# Eval("Sale_Lease_Unknown") %>' runat="server" id="Sale_Lease_UnknownLabel" Font-Size="11pt" Font-Names="Arial" Font-Bold="True" ForeColor="#0058B0" />
													<br>
													<span class="style34">
													<span class="style16">
													<asp:Label Text='<%# Eval("Unit_Type") %>' runat="server" id="Unit_TypeLabel" Font-Size="11pt" Font-Names="Arial" Font-Bold="True" ForeColor="Black" />
													</span></span><br>
													<span class="style34">
													<span class="style16">
													<asp:Label Text='<%# Eval("Unit_SF") %>' runat="server" id="Unit_SFLabel" Font-Size="11pt" Font-Names="Arial" />
													</span></span>Sq Ft</br>
													</br></td>
													<td valign="top" class="style35">
													<asp:Label Text='<%# Eval("Address") %>' runat="server" id="AddressLabel" Font-Size="Small" Font-Names="Arial" Font-Bold="True" />
													<br>
													<span class="style17">
													<asp:Label Text='<%# Eval("Town") %>' runat="server" id="TownLabel" Font-Size="Small" Font-Names="Arial" />
													</span>
													<span class="style36">,</span><span class="style17">
													<asp:Label Text='<%# Eval("State") %>' runat="server" id="StateLabel" Font-Size="Small" Font-Names="Arial" />
													<span class="style6">
													<asp:Label Text='<%# Eval("Zip") %>' runat="server" id="ZipLabel" Font-Size="Small" Font-Names="Arial" />
													</span></span></br></td>
												</tr>
											</table>
											<span class="style10">_________________________________________________________________________</span><br>
											</br>
										</ItemTemplate>
									</asp:DataList>
									<asp:AccessDataSource runat="server" ID="AccessDataSource2" DataFile="fpdb/downtownproperties.mdb" SelectCommand="SELECT [ID], [Address], [Town], [State], [Zip], [Unit_SF], [Sale_Lease_Unknown], [Unit_Type], [Picture], [Architectural_Design] FROM [Properties] WHERE ([Town] = ?)">
										<SelectParameters>
											<asp:controlparameter ControlID="DropDownList1" PropertyName="SelectedValue" Name="Town" Type="String" />
										</SelectParameters>
									</asp:AccessDataSource>
 


_____________________________

Swoooosh
Just Do It!


(in reply to swoosh)
swoosh

 

Posts: 1434
Joined: 5/18/2002
From: Beaver Falls, PA
Status: offline

 
RE: Default Value "null" for Dropdown - 5/15/2008 11:25:55   
I have tried the following:

 <asp:DataList runat="server" id="DataList1" DataKeyField="ID" DataSourceID="AccessDataSource2">
									
    
					if (Page.IsPostBack) {

myDatalist1.Visible = True 
Else 
myDatalist1.Visible = False 
End If }
  


But it gives me an error:

Line 63:
Line 64:
Line 65: if (Page.IsPostBack) {
Line 66:
Line 67: myDatalist1.Visible = True


Am I way off base with what I tried?

_____________________________

Swoooosh
Just Do It!


(in reply to swoosh)
rdouglass

 

Posts: 9167
From: Biddeford, ME USA
Status: offline

 
RE: Default Value "null" for Dropdown - 5/15/2008 11:30:24   
quote:

Am I way off base with what I tried?


No, I don't think so. You should just need to wrap it in <% and %> and get rid of those brackets.

<%
if (Page.IsPostBack)
myDatalist1.Visible = True
Else
myDatalist1.Visible = False
End If
%>

That help any?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to swoosh)
swoosh

 

Posts: 1434
Joined: 5/18/2002
From: Beaver Falls, PA
Status: offline

 
RE: Default Value "null" for Dropdown - 5/15/2008 11:44:47   
 <asp:DataList runat="server" id="DataList1" DataKeyField="ID" DataSourceID="AccessDataSource2">
									
									
<% 
if (Page.IsPostBack) 
myDatalist1.Visible = True 
Else 
myDatalist1.Visible = False 
End If 
%> 						<ItemTemplate>
	I<table style="width: 100%">
		<tr>
													<td>
													<asp:HyperLink runat="server" id="HyperLink1"  NavigateUrl='<%# Eval("ID", "~/details.aspx?ID={0}") %>'><asp:Image runat="server" id="Image1" ImageUrl='<%# Eval("Picture", "~/property_images/{0}") %>' Height="94px" Width="125px" BorderColor="black" BorderStyle="solid" BorderWidth="1px" />
													</asp:HyperLink>
													</td>
													<td>
													<asp:Label Text='<%# Eval("Address") %>' runat="server" id="AddressLabel" />
													<br>
													<asp:Label Text='<%# Eval("State") %>' runat="server" id="StateLabel" /> 
  



Results in error:

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Code blocks are not supported in this context.

Source Error:


Line 63:
Line 64:
Line 65: <%
Line 66: if (Page.IsPostBack)
Line 67: myDatalist1.Visible = True


Source File: /dtp.net/gsb.aspx Line: 65



< Message edited by swoosh -- 5/15/2008 11:53:14 >


_____________________________

Swoooosh
Just Do It!


(in reply to swoosh)
rdouglass

 

Posts: 9167
From: Biddeford, ME USA
Status: offline

 
RE: Default Value "null" for Dropdown - 5/15/2008 12:03:45   
quote:

AccessDataSource2


Well, we'll go back to my alternate solution. Do you have a default defined for that data source? Try setting the default to something that would not return any results.

Again, it's hard to do this without seeing the full code. That code I posted works fine on a code-behind page and I'm not at all sure how you have the page setup.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to swoosh)
swoosh

 

Posts: 1434
Joined: 5/18/2002
From: Beaver Falls, PA
Status: offline

 
RE: Default Value "null" for Dropdown - 5/15/2008 12:09:37   
Okay Roger I will try that later today. as for the DataSource2, that is the result source name.......DataSource1 is my dropdown source name.

So basicaly I'll try to put in a default for the results and see what happens. Thank You so much for your time. I'll post later after I have attempted. Thanks again

If I fail (what are the odds? LOL) I'll try posting the code for the entire page

_____________________________

Swoooosh
Just Do It!


(in reply to swoosh)
swoosh

 

Posts: 1434
Joined: 5/18/2002
From: Beaver Falls, PA
Status: offline

 
RE: Default Value "null" for Dropdown - 5/19/2008 9:43:08   
Added a default value of "an empty field" for the results and everything works now Roger. Thanks so much for your guidance!!!!

_____________________________

Swoooosh
Just Do It!


(in reply to swoosh)
Page:   [1]

All Forums >> Web Development >> Expression Web Help >> Default Value "null" for Dropdown
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts