I am teaching myself asp.net 2.0 using VB.NET 2005.
I want a dropdown to be set to the default week start date for the week when the web page is loaded. I have a dropdown list that has all the weeks for the year. Populated by one datasource. I have two data sources, the other has the current week starting date, which for this week is 7/25/09 Saturday. how do I set the dropdown list to default to the sql datasources sqlTmShtCurrentWeekEndDate WeekStartDate column?
DougP
< I Built one
I want a dropdown to be set to the default week start date for the week when the web page is loaded. I have a dropdown list that has all the weeks for the year. Populated by one datasource. I have two data sources, the other has the current week starting date, which for this week is 7/25/09 Saturday. how do I set the dropdown list to default to the sql datasources sqlTmShtCurrentWeekEndDate WeekStartDate column?
Code:
<form id="form1" runat="server">
<asp:SqlDataSource
id="sqlTmShtCurrentWeekStartDate" runat="server" ConnectionString="<%$ ConnectionStrings:webdb1ConnectionString %>"
SelectCommand="SELECT Top 1 WeekStartDate, WeekEndDate, WeekNumber, PayPeriodDate, PayPeriod FROM [Timesheet PayPeriods] WHERE (WeekEndDate >= getdate())">
</asp:SqlDataSource>
<asp:SqlDataSource
id="sqlTmShtAllPayPeriods" runat="server" ConnectionString="<%$ ConnectionStrings:webdb1ConnectionString %>"
SelectCommand="SELECT WeekStartDate, WeekEndDate, WeekNumber, PayPeriodDate, PayPeriod FROM [Timesheet PayPeriods]">
</asp:SqlDataSource>
<asp:DropDownList
id="DropDownList2"
runat="server"
DataTextField="WeekStartDate"
DataSourceID="sqlTmShtAllPayPeriods" style="z-index: 101; left: 384px; position: absolute; top: 48px" AutoPostBack="True"
DataTextFormatString= ??? <<<<<< this to format as 7/25/09 currently its 7/25/2009 12:00:00 AM
DataValueField= ?? <<<<< and this to be on 7/25/09
/>
<asp:Label ID="lblWeekEndDate" runat="server" Style="z-index: 103; left: 232px; position: absolute;
top: 48px" Text="Choose Week Start Date"></asp:Label>
</form>
DougP
< I Built one