DataSource controls really do work in ASP.NET Whidbey

I wrote some code in ASP.NET Whidbey last night to use the DataSource controls.  Wow, this stuff really does work.  I used it to perform some queries against my Web Search with .NET code.  Here it is and it actually does work.  There is a drop down list box that is populated with the server name.  On a change of the server name drop down, the grid on the page changes and displays all of the items that are found in the database that are associated with that domain name.  The one question that I have had is how would you put a blank item into the drop down list box as the selected item and keep the query from running the first time thru?  I assume it is something in the Page_Load event.  Suggestions?

Wally

<%@ Page Language="C#" MasterPageFile="~/ExampleMasterPage.master" Title="Data Source Controls"%>

<asp:Content ID="cExample" ContentPlaceHolderID="cph1" Runat="server"><asp:DropDownList

ID="ddlDomainName" Runat="server" DataSourceID="sqldsDDL" DataTextField="DomainName"

DataValueField="DomainName" AutoPostBack="True">

</asp:DropDownList>

<asp:SqlDataSource ID="sqldsResults" Runat="server" SelectCommand="SELECT [SearchUrl] FROM [tblSearchResults] WHERE ([DomainName] = @DomainName)"

ConnectionString="<%$ ConnectionStrings:sqlResultsConnection %>">

<SelectParameters>

<asp:ControlParameter Name="DomainName" Type="String" ControlID="ddlDomainName" PropertyName="SelectedValue"></asp:ControlParameter>

</SelectParameters>

</asp:SqlDataSource>

<asp:SqlDataSource ID="sqldsDDL" Runat="server" SelectCommand="SELECT DISTINCT DomainName FROM dbo.tblSearchResults"

ConnectionString="<%$ ConnectionStrings:DDLLookupString %>">

</asp:SqlDataSource>

<asp:DataList ID="dlResults" Runat="server" DataSourceID="sqldsResults">

<ItemTemplate>

SearchUrl:

<asp:Label Text='<%# Eval("SearchUrl") %>' Runat="server" ID="SearchUrlLabel">

</asp:Label><br />

<br />

</ItemTemplate>

</asp:DataList>

</asp:Content>

3 Comments

Comments have been disabled for this content.