473,394 Members | 1,742 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,394 software developers and data experts.

how to set the value in html select control

hi,

I have the following piece of html code in a page
<table width="90%" border="0" align="left" cellpadding="0" cellspacing="0">

<tr>

<td width="26%">&nbsp;&nbsp;&nbsp;day</td>

<td width="40%">month</td>

<td width="34%">year</td>

</tr>

<tr>

<td align="left">

<select name="dobday" id="dobday" style="width:47" tabindex="9"
runat="server"></select>

</td>

<td align="center">

<select name="dobmonth" id="dobmonth" style="width:54" tabindex="10"
runat="server">

<option value="1">JAN</option>

<option value="2">FEB</option>

<option value="3">MAR</option>

<option value="4">APR</option>

<option value="5">MAY</option>

<option value="6">JUN</option>

<option value="7">JUL</option>

<option value="8">AUG</option>

<option value="9">SEP</option>

<option value="10">OCT</option>

<option value="11">NOV</option>

<option value="12">DEC</option>

</select>

</td>

<td align="left">

<input type="text" name="dobyear" id="dobyear" maxlength="4" value="19"
size="3" tabindex="11" runat="server"/>

</td>

</tr>

</table>

and i am trying to assign the value from the server side . The server side
code is as below which uses the system.globalization namespace and all other
relavant namespaces.

DateTime dt;

CultureInfo dtCulture = new CultureInfo("en-US");

dt = DateTime.Parse(Convert.ToString(Session["DOB"]), dtCulture,
DateTimeStyles.NoCurrentDateDefault);

dobday.Value = Convert.ToString(dt.Date);

dobmonth.Value = Convert.ToString(dt.Month);

dobyear.Value = Convert.ToString(dt.Year);

The dt.Date, dt.Month give the correct information but the value is not
assigned correctly in the html select boxes. Please let me know why the
value is not being set?

Regards,

shafi


Jan 31 '06 #1
1 5349
Hello,

Try using dt.Day instead of dt.Date.

Otherwise, your code works just fine.

--
James Johansen, Longhorn SDK
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
--------------------
From: "Mohammed Shafiulla Khadri" <md***********@hotmail.com>
Subject: how to set the value in html select control
Date: Tue, 31 Jan 2006 19:19:47 +0530
Lines: 104
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
X-RFC2646: Format=Flowed; Original
Message-ID: <ey**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: 202.56.254.61
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP10.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.languages.csharp:382323
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

hi,

I have the following piece of html code in a page
<table width="90%" border="0" align="left" cellpadding="0" cellspacing="0">

<tr>

<td width="26%">&nbsp;&nbsp;&nbsp;day</td>

<td width="40%">month</td>

<td width="34%">year</td>

</tr>

<tr>

<td align="left">

<select name="dobday" id="dobday" style="width:47" tabindex="9"
runat="server"></select>

</td>

<td align="center">

<select name="dobmonth" id="dobmonth" style="width:54" tabindex="10"
runat="server">

<option value="1">JAN</option>

<option value="2">FEB</option>

<option value="3">MAR</option>

<option value="4">APR</option>

<option value="5">MAY</option>

<option value="6">JUN</option>

<option value="7">JUL</option>

<option value="8">AUG</option>

<option value="9">SEP</option>

<option value="10">OCT</option>

<option value="11">NOV</option>

<option value="12">DEC</option>

</select>

</td>

<td align="left">

<input type="text" name="dobyear" id="dobyear" maxlength="4" value="19"
size="3" tabindex="11" runat="server"/>

</td>

</tr>

</table>

and i am trying to assign the value from the server side . The server side
code is as below which uses the system.globalization namespace and all otherrelavant namespaces.

DateTime dt;

CultureInfo dtCulture = new CultureInfo("en-US");

dt = DateTime.Parse(Convert.ToString(Session["DOB"]), dtCulture,
DateTimeStyles.NoCurrentDateDefault);

dobday.Value = Convert.ToString(dt.Date);

dobmonth.Value = Convert.ToString(dt.Month);

dobyear.Value = Convert.ToString(dt.Year);

The dt.Date, dt.Month give the correct information but the value is not
assigned correctly in the html select boxes. Please let me know why the
value is not being set?

Regards,

shafi



Jan 31 '06 #2

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

Similar topics

1
by: TDN | last post by:
Hi, I expect to see "foo" for the 2nd alert. Instead, the value of select is cleared. Am I missing something? Thanks for your help. <html> <head><title>Foo</title> <script...
12
by: Mark Kurten | last post by:
i have the code below: for starters the value of txtempid = 1 after i go through this routine (i put a break point on the txtname.value line), the value of txtEmpID is 2 (Just like it is...
2
by: Alani | last post by:
Hello All, I'm a new ASP.NET programmer and I want to create a custom control consist of two properties (Number1) and (Number2) and both of them are integers and default value = 0, now I'm...
7
by: skeddy | last post by:
In a nutshell, I'm trying to dynamically create a select box with ResultSet code in vbscript and then need to be able to access the value of that select box later with a Save button. I've got...
3
by: dcassar | last post by:
I am working on a complex server control that dynamically creates an HtmlInputHidden control that stores its value. As far as the postback process is concerned, this hidden input acts as the...
4
by: TS | last post by:
In my production exceptions i get an email with all the form elements and their values to debug. the controls that have a blank value are not seen and it makes my debug job harder (was the...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
2
by: Gary Dale | last post by:
I have a form with a pull-down list with six options, each of which has a value set. The value is the e-mail account name (without the domain) of a group while the displayed value is the full name...
2
by: j.t.w | last post by:
This is probably very easy. How do I set an HTML select control's value from the querystring? This is what I have...but, only the select control's value doesn't get set. CustomerSelect.Value...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...

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.