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"] + "'";
Tim Van Wassenhove - 24 Aug 2007 15:23 GMT
> 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/infinitiesloop/archive/2006/08/03/Truly-Understanding-Vie
wstate.aspx
to get a better unstanding.

Signature
Kind regards,
Tim Van Wassenhove <url:http://www.timvw.be/>
gsauns - 24 Aug 2007 16:48 GMT
On Aug 24, 10:23 am, Tim Van Wassenhove <ti...@newsgroup.nospam>
wrote:
> > 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
[quoted text clipped - 8 lines]
> 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,
Tim Van Wassenhove - 24 Aug 2007 21:21 GMT
> On Aug 24, 10:23 am, Tim Van Wassenhove <ti...@newsgroup.nospam>
> wrote:
[quoted text clipped - 14 lines]
> 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...

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