Error in exposing SelectedItem property of dropdownlist in a usercontrol [Resolved]

Posted by Shivamthinks under ASP.NET on 6/19/2012 | Points: 10 | Views : 997 | Status : [Member] | Replies : 3
public object SelectedItem
{
get
{
return GetSelectedItem();
}
set;
}


I am trying to expose SelectedItem property of dropdownlist in a user control. But i am getting error in GetSelectedItem();

How do i expose SelectedItem property of dropdown list ?

Please reply.

Thanks.




Responses

Posted by: Ajay.Kalol on: 6/21/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Nothing to write more code. just write get; set; as per my answer,

this is new feature of c# 3.0 called automatic property.


use this for setting value

SelectedItem = ddl.selectedValue.


use this for getting Value,

ddl.selectedValue = SelectedItem


Ajay
ajaypatelfromsanthal.blogspot.in

Shivamthinks, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ajay.Kalol on: 6/19/2012 [Member] Starter | Points: 25

Up
0
Down
public object SelectedItem
{
get; set;
{

use this.
for setting value
SelectedItem = ddl.selectedValue.

for getting Value,

ddl.selectedValue = SelectedItem

Ajay
ajaypatelfromsanthal.blogspot.in

Shivamthinks, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shivamthinks on: 6/19/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks Ajay.

This is what i am asking what to write in get and set so as when i use SelectedItem property it should act as it is acting for dropdownlist.

Please reply.

Thanks.

Shivamthinks, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response