473,288 Members | 2,350 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,288 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 1577
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.