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

DropDownList.SelectedValue

CK
Hi All,
I have a class and one property is an Enum. I am trying to persist the
DropDownList.SelectedValue to the class property.
I am using
job.ExpRelated =
Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);

but it doesn't build. Any ideas anyone?

Thanks All,

~CK
May 17 '06 #1
8 1580
Do you get an error?

Break it into pieces...hard-code SelectedValue etc until you find why it
isn't working

"CK" <c_**********@hotmail.com> wrote in message
news:qx******************@newssvr11.news.prodigy.c om...
Hi All,
I have a class and one property is an Enum. I am trying to persist the
DropDownList.SelectedValue to the class property.
I am using
job.ExpRelated =
Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);

but it doesn't build. Any ideas anyone?

Thanks All,

~CK

May 17 '06 #2
CK
I am sorry. I am a beginner. I am not quite sure what you mean.
How do I do that?

"Jeff Dillon" <je********@hotmail.com> wrote in message
news:uD**************@TK2MSFTNGP05.phx.gbl...
Do you get an error?

Break it into pieces...hard-code SelectedValue etc until you find why it
isn't working

"CK" <c_**********@hotmail.com> wrote in message
news:qx******************@newssvr11.news.prodigy.c om...
Hi All,
I have a class and one property is an Enum. I am trying to persist the
DropDownList.SelectedValue to the class property.
I am using
job.ExpRelated =
Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);

but it doesn't build. Any ideas anyone?

Thanks All,

~CK


May 17 '06 #3
Instead of ddlExpRelated.SelectedValue, hard-code a specific value.

Did you copy this code? Beginners generally don't know about Enum's and
typeof...

start with Job.ExpRelated = value

then add pieces in one at a time to see where it's failing

And post your error message

Jeff

"CK" <c_**********@hotmail.com> wrote in message
news:1T*******************@newssvr11.news.prodigy. com...
I am sorry. I am a beginner. I am not quite sure what you mean.
How do I do that?

"Jeff Dillon" <je********@hotmail.com> wrote in message
news:uD**************@TK2MSFTNGP05.phx.gbl...
Do you get an error?

Break it into pieces...hard-code SelectedValue etc until you find why it
isn't working

"CK" <c_**********@hotmail.com> wrote in message
news:qx******************@newssvr11.news.prodigy.c om...
Hi All,
I have a class and one property is an Enum. I am trying to persist the
DropDownList.SelectedValue to the class property.
I am using
job.ExpRelated =
Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);

but it doesn't build. Any ideas anyone?

Thanks All,

~CK



May 17 '06 #4
Try this:
job.ExpRelated = (ExpRelated)
Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);

Hope that works.

- Rajib
"CK" <c_**********@hotmail.com> wrote in message
news:qx******************@newssvr11.news.prodigy.c om...
Hi All,
I have a class and one property is an Enum. I am trying to persist the
DropDownList.SelectedValue to the class property.
I am using
job.ExpRelated =
Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);

but it doesn't build. Any ideas anyone?

Thanks All,

~CK

May 17 '06 #5
CK
Well this works.
job.ExpRelated = ExperienceRelated.Directly;

I basically wanted to grab the value from the dropdown and cast it as an
Enum.

Any ideas? I can't give you an error as it doesn't compile. The compiler
gives me a typecasting error.

E:\Web Projects\EmploymentSolution\Employment\AppEmployme ntCtl.ascx.cs(390):
Cannot implicitly convert type 'object' to
'Employment.Library.ExperienceRelated'


"Jeff Dillon" <je********@hotmail.com> wrote in message
news:Ot**************@TK2MSFTNGP02.phx.gbl...
Instead of ddlExpRelated.SelectedValue, hard-code a specific value.

Did you copy this code? Beginners generally don't know about Enum's and
typeof...

start with Job.ExpRelated = value

then add pieces in one at a time to see where it's failing

And post your error message

Jeff

"CK" <c_**********@hotmail.com> wrote in message
news:1T*******************@newssvr11.news.prodigy. com...
I am sorry. I am a beginner. I am not quite sure what you mean.
How do I do that?

"Jeff Dillon" <je********@hotmail.com> wrote in message
news:uD**************@TK2MSFTNGP05.phx.gbl...
Do you get an error?

Break it into pieces...hard-code SelectedValue etc until you find why it
isn't working

"CK" <c_**********@hotmail.com> wrote in message
news:qx******************@newssvr11.news.prodigy.c om...
Hi All,
I have a class and one property is an Enum. I am trying to persist the
DropDownList.SelectedValue to the class property.
I am using
job.ExpRelated =
Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);

but it doesn't build. Any ideas anyone?

Thanks All,

~CK



May 17 '06 #6
Your initial statement is basically converting it to an object. Assuming the
assignment works correctly all you needed to do a type cast to
ExperienceRelated.

Updated statement:

job.ExpRelated = (ExperienceRelated)
Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);

"CK" <c_**********@hotmail.com> wrote in message
news:Kk*******************@newssvr11.news.prodigy. com...
Well this works.
job.ExpRelated = ExperienceRelated.Directly;

I basically wanted to grab the value from the dropdown and cast it as an
Enum.

Any ideas? I can't give you an error as it doesn't compile. The compiler
gives me a typecasting error.

E:\Web
Projects\EmploymentSolution\Employment\AppEmployme ntCtl.ascx.cs(390):
Cannot implicitly convert type 'object' to
'Employment.Library.ExperienceRelated'


"Jeff Dillon" <je********@hotmail.com> wrote in message
news:Ot**************@TK2MSFTNGP02.phx.gbl...
Instead of ddlExpRelated.SelectedValue, hard-code a specific value.

Did you copy this code? Beginners generally don't know about Enum's and
typeof...

start with Job.ExpRelated = value

then add pieces in one at a time to see where it's failing

And post your error message

Jeff

"CK" <c_**********@hotmail.com> wrote in message
news:1T*******************@newssvr11.news.prodigy. com...
I am sorry. I am a beginner. I am not quite sure what you mean.
How do I do that?

"Jeff Dillon" <je********@hotmail.com> wrote in message
news:uD**************@TK2MSFTNGP05.phx.gbl...
Do you get an error?

Break it into pieces...hard-code SelectedValue etc until you find why
it isn't working

"CK" <c_**********@hotmail.com> wrote in message
news:qx******************@newssvr11.news.prodigy.c om...
> Hi All,
> I have a class and one property is an Enum. I am trying to persist the
> DropDownList.SelectedValue to the class property.
> I am using
> job.ExpRelated =
> Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);
>
> but it doesn't build. Any ideas anyone?
>
> Thanks All,
>
> ~CK
>
>



May 17 '06 #7
You just gave me the error. Do as the error suggests?

"CK" <c_**********@hotmail.com> wrote in message
news:Kk*******************@newssvr11.news.prodigy. com...
Well this works.
job.ExpRelated = ExperienceRelated.Directly;

I basically wanted to grab the value from the dropdown and cast it as an
Enum.

Any ideas? I can't give you an error as it doesn't compile. The compiler
gives me a typecasting error.

E:\Web
Projects\EmploymentSolution\Employment\AppEmployme ntCtl.ascx.cs(390):
Cannot implicitly convert type 'object' to
'Employment.Library.ExperienceRelated'


"Jeff Dillon" <je********@hotmail.com> wrote in message
news:Ot**************@TK2MSFTNGP02.phx.gbl...
Instead of ddlExpRelated.SelectedValue, hard-code a specific value.

Did you copy this code? Beginners generally don't know about Enum's and
typeof...

start with Job.ExpRelated = value

then add pieces in one at a time to see where it's failing

And post your error message

Jeff

"CK" <c_**********@hotmail.com> wrote in message
news:1T*******************@newssvr11.news.prodigy. com...
I am sorry. I am a beginner. I am not quite sure what you mean.
How do I do that?

"Jeff Dillon" <je********@hotmail.com> wrote in message
news:uD**************@TK2MSFTNGP05.phx.gbl...
Do you get an error?

Break it into pieces...hard-code SelectedValue etc until you find why
it isn't working

"CK" <c_**********@hotmail.com> wrote in message
news:qx******************@newssvr11.news.prodigy.c om...
> Hi All,
> I have a class and one property is an Enum. I am trying to persist the
> DropDownList.SelectedValue to the class property.
> I am using
> job.ExpRelated =
> Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);
>
> but it doesn't build. Any ideas anyone?
>
> Thanks All,
>
> ~CK
>
>



May 17 '06 #8
CK
I get:
Object reference not set to an instance of an object

when I use:
(ExperienceRelated)Enum.ToObject(typeof(Experience Related),ddlExpRelated.SelectedValue);

and I get:
E:\Web Projects\EmploymentSolution\Employment\AppEmployme ntCtl.ascx.cs(390):
The type or namespace name 'ExpRelated' could not be found (are you missing
a using directive or an assembly reference?)

when I use:
(ExpRelated)Enum.ToObject(typeof(ExperienceRelated ),ddlExpRelated.SelectedValue);

Any other ideas anyone? I know this should be doable.

Thanks,

~CK

"Rajib" <ra****@e-2-d.com> wrote in message
news:u8**************@TK2MSFTNGP03.phx.gbl...
Try this:
job.ExpRelated = (ExpRelated)
Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);

Hope that works.

- Rajib
"CK" <c_**********@hotmail.com> wrote in message
news:qx******************@newssvr11.news.prodigy.c om...
Hi All,
I have a class and one property is an Enum. I am trying to persist the
DropDownList.SelectedValue to the class property.
I am using
job.ExpRelated =
Enum.ToObject(typeof(ExperienceRelated),ddlExpRela ted.SelectedValue);

but it doesn't build. Any ideas anyone?

Thanks All,

~CK


May 18 '06 #9

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

Similar topics

4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
2
by: Benedict Teoh | last post by:
I created a dropdownlist containing day, month and year field and expose a property to assign a date. When I call from a aspx page and assign the value, the new date is not displayed until a submit...
3
by: sling blade | last post by:
Hi, I have a dropdownlist in my DataList control and I am trying to set the SelectedItem property of the dropdownlist so when the datalist displays the user will see the text in the dropdownlist...
15
by: Swetha | last post by:
Hello I have a DropDownList that I am populating using the following SqlDataSource: <asp:DropDownList ID="parentIDDropDownList" runat="server" DataSourceID="SqlDataSource3"...
3
by: Carlos Lozano | last post by:
Hello, I am having a problem getting the selectedValue from a dropdownlist that is populated with a dataReader and just can't see the problem. I did the following: dim dr as DataReader dr...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
3
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
Hi, Trouble in retaining values of dropdownlist, textboxes, and other controls when dropdownlist selectedindexchanged event is triggered, the controls are inside a user control and this user...
2
by: sree reddy | last post by:
..cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls;
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
6
by: shashi shekhar singh | last post by:
Respected Sir, I have to create multiple dynamic dropdownlist boxes and add items dynamically in <asp:table> server control but problem occurs , i.e. except of fist dropdown list no dropdownlist...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.