473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

selection in dropdownlist


i am displaying days of month
and want that today day should be selected by default how can i do that

DateTime str;
str=DateTime.Now;
int DayToday=str.Day;
for(int i=1;i<=31;i++)
{
DropDownList1.Items.Add(i.ToString());
}
Nov 19 '05 #1
4 966
DropDownList1.Items.FindByValue(DateTime.Now.ToStr ing("dd")).Selected =
true;

HTH

"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

i am displaying days of month
and want that today day should be selected by default how can i do that

DateTime str;
str=DateTime.Now;
int DayToday=str.Day;
for(int i=1;i<=31;i++)
{
DropDownList1.Items.Add(i.ToString());
}

Nov 19 '05 #2
DropDownList1.SelectedIndex=DayToday-1;

Eliyahu

"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

i am displaying days of month
and want that today day should be selected by default how can i do that

DateTime str;
str=DateTime.Now;
int DayToday=str.Day;
for(int i=1;i<=31;i++)
{
DropDownList1.Items.Add(i.ToString());
}

Nov 19 '05 #3
solved like this
for(int i=1;i<=31;i++)

{

DropDownList1.Items.Add(i.ToString());

}

DropDownList1.SelectedValue =DayToday.ToString();

"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:#g**************@TK2MSFTNGP09.phx.gbl...

i am displaying days of month
and want that today day should be selected by default how can i do that

DateTime str;
str=DateTime.Now;
int DayToday=str.Day;
for(int i=1;i<=31;i++)
{
DropDownList1.Items.Add(i.ToString());
}

Nov 19 '05 #4
"Ankit Aneja" <ef*****@newsgroups.nospam> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
i am displaying days of month
and want that today day should be selected by default how can i do that

DateTime str;
str=DateTime.Now;
int DayToday=str.Day;
for(int i=1;i<=31;i++)
{
DropDownList1.Items.Add(i.ToString());
}


Something like:
DropDownList1.Items.FindByText(DayToday.ToString() ).Selected = true;

N.B. This is just from memory, so you may have to tweak it a bit...
Nov 19 '05 #5

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

Similar topics

0
by: Russ | last post by:
Hi, I have found myself wanting to use an HTMLSelect control instead of a DropDownList so that I can programatically set the item colours in the list (not possible with DropDownList due to...
2
by: sklett | last post by:
Hi- I'm a bit rusty cause it's been awhile since I've made an asp.net app, but here is what I want to do: single aspx page bound DropDownList w/ autopost back that holds names of customers...
5
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
1
by: Michael Groeger | last post by:
Hi, I want to be able to have a DropDownList which supports multiple selection, but I haven't found a property for that in the DropDownList control. Is there a way to have multiple selection...
0
by: Chris Zopers | last post by:
Hello, I have developed an ASP.NET page, with a dropdownlist and some textboxes. When a selection is made in the dropdownlist, some data is retrieved from a database and displayed in the...
0
by: Chris Zopers | last post by:
Hello, I have developed an ASP.NET page, with a dropdownlist and some textboxes. When a selection is made in the dropdownlist, some data is retrieved from a database and displayed in the...
1
by: Chris Zopers | last post by:
Hello, I have developed an ASP.NET page, with a dropdownlist and some textboxes. When a selection is made in the dropdownlist, some data is retrieved from a database and displayed in the...
10
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code:...
0
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box...
5
by: =?Utf-8?B?U2F0aXNo?= | last post by:
C#, ASP.NET Q: Have a formview, with a dropdownlist which is bound to a column. This dropdownlist has a datasource of DataSet type. Now my objective is, on Selection Changed of this DropdownList,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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,...

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.