to be the same as the value). I changed this to a character as that
is what I want to have in my database.
<asp:dropdownlist
style="border:none" id="recurrenceType"
runat="server">
<asp:listitem value="N"
>None</asp:listitem>
<asp:listitem value="M"
>Monthly</asp:listitem>
<asp:listitem value="P"
>Periodic</asp:listitem>
</asp:dropdownlist
I was setting the value before (when the value was "0", "1" and "2").
It used to work like this:
recurrenceType.SelectedIndex = objDataReader("recurrenceType")
How would I set it with the value set to a char?
Thanks,
Tom.
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.comI have tried all kinds of ways to get this to work and keep getting
strange (at least to me) results.
If I do a viewsource of the above statement (my last post):
recurrenceType.SelectedItem.value = "P"
I get the following:
<select name="recurrenceType" id="recurrenceType"
style="border:none">
<option selected="selected" value="P">None</option>
<option value="M">Monthly</option>
<option value="P">Periodic</option>
</select
It seems to change the value, which I guess is what I am saying - but
this is how I saw it selected in one example. I am trying to get it
to move the selected="selected" to the 3rd option and it isn't doing
it.
I then tried:
recurrenceType.Items.FindByValue("P").selected = true
And got the following error:
A DropDownList cannot have multiple items selected.
Description: An unhandled exception occurred during the execution
of the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A DropDownList
cannot have multiple items selected.
Source Error:
Line 132: </table>
Line 133:
Line 134: <form runat="server">
Line 135: <table align="center">
Line 136: <tr
valign="baseline"
This is driving me crazy.
Thanks,
Tom.
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.com
I just tried this:
recurrenceType.SelectedItem.value = "P"
The display on the screen is still "None".
Thanks,
Tom.
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.com
The syntax should be something close to this:
recurrenceType.SelectedItem=recurrenceType.Items.F indByValue("P")
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"tfs" <tfs@.dslextreme-dot-com.no-spam.invalid> wrote in message
news:40eb0582$1_1@.Usenet.com...
> I have a dropdownlist that I was setting to an index (which happened
> to be the same as the value). I changed this to a character as that
> is what I want to have in my database.
> <asp:dropdownlist
> style="border:none" id="recurrenceType"
> runat="server">
> <asp:listitem value="N"
> >None</asp:listitem>
> <asp:listitem value="M"
> >Monthly</asp:listitem>
> <asp:listitem value="P"
> >Periodic</asp:listitem>
> </asp:dropdownlist>
>
> I was setting the value before (when the value was "0", "1" and "2").
> It used to work like this:
> recurrenceType.SelectedIndex = objDataReader("recurrenceType")
> How would I set it with the value set to a char?
> Thanks,
> Tom.
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ------------------
> http://www.usenet.com
I think what you are looking for is -
((ListItem)recurrenceType.Items.FindByValue("P")).Selected = true;
Bobby Ryzhy
bobby@.weekendtech.net
http://www.weekendtech.net
On Tue, 6 Jul 2004 14:43:16 -0700, "Steve C. Orr [MVP, MCSD]"
<Steve@.Orr.net> wrote:
>The syntax should be something close to this:
>recurrenceType.SelectedItem=recurrenceType.Items.F indByValue("P")
Yes, I believe that is more precise.
"Bobby Ryzhy" <bryzhy@.hotmail.com> wrote in message
news:vt8me0l7uanmgb9iln5o7nsvbal012e867@.4ax.com...
> I think what you are looking for is -
> ((ListItem)recurrenceType.Items.FindByValue("P")).Selected = true;
> Bobby Ryzhy
> bobby@.weekendtech.net
> http://www.weekendtech.net
>
> On Tue, 6 Jul 2004 14:43:16 -0700, "Steve C. Orr [MVP, MCSD]"
> <Steve@.Orr.net> wrote:
> >The syntax should be something close to this:
> >recurrenceType.SelectedItem=recurrenceType.Items.F indByValue("P")
SelectValue was it.
Here is what I did that works fine.
recurrenceType.SelectedValue =
objDataReader("recurrenceType")
recurrenceDisplay.text = recurrenceType.SelectedItem.text
<td nowrap align="right">Recurrance:</td>
<td>
<asp:label id="recurrenceDisplay"
runat="server" />
<asp:dropdownlist style="visibility:hidden"
id="recurrenceType" runat="server">
<asp:listitem value="N"
>None</asp:listitem>
<asp:listitem value="M"
>Monthly</asp:listitem>
<asp:listitem value="P"
>Periodic</asp:listitem>
</asp:dropdownlist>
</td
Thanks,
Tom
Posted Via Usenet.com Premium Usenet Newsgroup Services
------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
------------------
http://www.usenet.com
0 comments:
Post a Comment