How to use editable dropdownlist in Gridview [Resolved]

Posted by Shivamthinks under ASP.NET on 6/18/2012 | Points: 10 | Views : 3532 | Status : [Member] | Replies : 4
Hi

I have creaded a gridview.
I have created a editable dropdownlist user control. I want this user control to be used in GridView.
I am able to use that user control in gridview also.

Problem: The editable dropdown list user control which i have used in Gridview. In that i am not able to use drodownlist and its properties like selected item, selected value exclusively.
I want to know how to access a particular dropdownlist in a editable dropdownlist user control.

Please reply.
Thanks




Responses

Posted by: Jpchoudhari on: 6/19/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
this should help u

public ListItem SelectedItem

{
get { return DropDownList1.SelectedItem; }
}

public object DataSource
{
get { return DropDownList1.DataSource ; }
set { DropDownList1.DataSource = value; }
}

public string DataTextField
{
get { return DropDownList1.DataTextField; }
set { DropDownList1.DataTextField = value; }
}


Kind Regards,
Jay

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

Posted by: Jpchoudhari on: 6/18/2012 [Member] Starter | Points: 25

Up
0
Down
u have to expose dropdown's properties like SelectedValue or selectedindex or any other property through public properties then you can use it in your page .

for ex. Create this property in code behind of your usercontrol to Set or access dropdownlist's selected value

public string SelectedValue
{
get { return ddlName.SelectedValue; }
set { ddlName.SelectedValue = value; }
}
this way you can create a read-write or read only properties to set or access the dropdown list's values

Kind Regards,
Jay

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 a lot Jay. It really helped.

I want two more properties of the dropdown list to be accessible which are SelectedItem, DataSource and DataTextField.
Can you please solve this problem and reply with the code ?

Please reply.

Thanks.

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 a lot.
It really helped me.

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

Login to post response