473,466 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Web DropDownList set to next date

Hello,

I have an ASP.NET app with a DropDownList on the page, which is bound
to values from a table. I have a Repeater control on the page whose
displayed data is dependent on the DropDownList value selected by the
user. (The DataTextField is a Datetime concatenated with a string).

On the Page_Load event, if it's not a postback, I would like the
DropDownList to programmatically be set to the next occurring day in
the DropDownList (the date values are in the table in fairly regular
weekly intervals). For example, if today is 8/23/07, I would like,
upon opening the page, the DropDownList to select 8/25/07 (if that is
the next occurring day in the data) and display the appropriate data
below.

I'm having no luck... any help?
-Here's my ASP.NET code for the controls:

<asp:SqlDataSource ID="sqldsDayList" runat="server" ConnectionString="<
%$ ConnectionStrings:ConnectionStringNew %>"
SelectCommand="SELECT [key], CONVERT(varchar(10), [day_dt], 1) + ' - '
+ [day_cd] As Day FROM [Table]"></asp:SqlDataSource>

<asp:DropDownList ID="ddlDaySelect" runat="server"
DataSourceID="sqldsDayList" DataTextField="Day" DataValueField="key"
AutoPostBack="true">
</asp:DropDownList>

<!--- For the repeater: -->
<asp:SqlDataSource ID="sqldsCreds" runat="server" ConnectionString="<%
$ ConnectionStrings:ConnectionStringNew %>"
SelectCommand="SELECT * FROM Credit">
</asp:SqlDataSource>

<asp:Repeater ID="rptrCredListing" runat="server"
DataSourceID="sqldsCreds">

-And now the C# code for my ddlDaySelect.OnSelectedIndexChanged:

sqldsCreds.SelectCommand = "SELECT Credit.*, Type.credit_type AS
credit_type FROM Credit, Type WHERE Credit.ctype_id = Type.ctype_id
AND key=" + ddlDaySelect.SelectedValue AND created = '" +
(string)Session["Username"] + "'";

Aug 23 '07 #1
3 2709
On 2007-08-23, gsauns <gs****@gmail.comwrote:
I have an ASP.NET app with a DropDownList on the page, which is bound
to values from a table. I have a Repeater control on the page whose
displayed data is dependent on the DropDownList value selected by the
user. (The DataTextField is a Datetime concatenated with a string).
At which time is the databinding performed? At the Page_Load event?
In that case you may want to read http://weblogs.asp.net/infinitiesloo...Viewstate.aspx
to get a better unstanding.

--
Kind regards,
Tim Van Wassenhove <url:http://www.timvw.be/>
Aug 24 '07 #2
On Aug 24, 10:23 am, Tim Van Wassenhove <ti...@newsgroup.nospam>
wrote:
On 2007-08-23, gsauns <gsa...@gmail.comwrote:
I have an ASP.NET app with a DropDownList on the page, which is bound
to values from a table. I have a Repeater control on the page whose
displayed data is dependent on the DropDownList value selected by the
user. (The DataTextField is a Datetime concatenated with a string).

At which time is the databinding performed? At the Page_Load event?
In that case you may want to readhttp://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Unders...
to get a better unstanding.

--
Kind regards,
Tim Van Wassenhove <url:http://www.timvw.be/>
Thanks. Yea the data source is set in the control's declaration and is
not changed at all. I will read the entire article when I have time,

Aug 24 '07 #3
On 2007-08-24, gsauns <gs****@gmail.comwrote:
On Aug 24, 10:23 am, Tim Van Wassenhove <ti...@newsgroup.nospam>
wrote:
>On 2007-08-23, gsauns <gsa...@gmail.comwrote:
I have an ASP.NET app with a DropDownList on the page, which is bound
to values from a table. I have a Repeater control on the page whose
displayed data is dependent on the DropDownList value selected by the
user. (The DataTextField is a Datetime concatenated with a string).

At which time is the databinding performed? At the Page_Load event?
In that case you may want to readhttp://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Unders...
to get a better unstanding.

--
Kind regards,
Tim Van Wassenhove <url:http://www.timvw.be/>

Thanks. Yea the data source is set in the control's declaration and is
not changed at all. I will read the entire article when I have time,
A possible 'shortcut' is to add the control and bind it in the Page_Init
eventhandler...
--
Kind regards,
Tim Van Wassenhove <url:http://www.timvw.be/>
Aug 24 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
2
by: Benedict Teoh | last post by:
I created a dropdownlist containing day, month and year field and expose a property to assign a date. When I call from a aspx page and assign the value, the new date is not displayed until a submit...
1
by: Vagabond Software | last post by:
I'm using a DropDownList in an EditItemTemplate column. This DropDownList will only ever have two dates in it; Now and the default DateTime value (1/1/1900 12:00:00 AM). Somewhere, somehow, the...
5
by: Victorious1 | last post by:
Why doesn't the the SelectedIndexchanged event for my dropdownlist ever get executed? Why do I get a page not found error when I select a new item? My dropdownlist is within a form. The items...
7
by: =?Utf-8?B?UmVraGE=?= | last post by:
Hi, I am trying to change the font color for the items in a dropdownlist control at run time using ASP.NET 2.0. DropDownList1.Items.Attributes.Add("style", "color:red"); But when I run the...
1
by: mark4asp | last post by:
I moved a page to another web-site and now it's broke! I had 5 pages in their own web-site. These pages have now been moved to another web-site. Everything is fine except that one of the pages,...
0
by: RosH | last post by:
Hi Everyone, I have a CreateUserWizard my public sign up page of my website. I have edited the wizard to include collection of other personal information. I have a DropDownList for the...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.