471,337 Members | 1,083 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 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 5237
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Mark Kurten | last post: by
3 posts views Thread by dcassar | last post: by
2 posts views Thread by Gary Dale | last post: by
2 posts views Thread by j.t.w | last post: by

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.