Custom dropdown

Vadlamani . asked on October 3, 2020 18:37

Hi, I need to create a dropdown webpart and user should add the items dynamically. Can we do it without custom table ? Any other approach?

Correct Answer

Brenden Kehren answered on October 4, 2020 17:06

You could. Use a text area and define the items as a pare per line like the drop-down control does.

value1;Display Text value2:Some More Text

Then when you bind the drop-down just parse out the values based on new lines and splitting the string

1 votesVote for this answer Unmark Correct answer

Recent Answers


David te Kloese answered on October 5, 2020 08:58

You can basically use anything you want... keep in mind that you might want the value to be more persistent.

  • child pages; where you'd use NodeGUID - PageName
  • Categories (you can even only use the categories assigned to the current page)
  • Build a custom form control that would store the data in the format Brenden described above
  • You could even go as far as building a Custom class to select from

If just the management is an issue you could also use the custom table for managing the items, and on the page tab of the page use a multi select that would allow an editor to select which items to use in your Web Part

0 votesVote for this answer Mark as a Correct answer

Vadlamani . answered on October 10, 2020 14:30

Thanks Brenden! A question, having that split logic and binding the values to the asp:dropdown control in the layout (layout tab in webpart or widget) will this have any impact on performance?

Could you suggest which approach is best suited?

Can we go with layouts or code behind as we need to have 50 dropdown items?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on October 10, 2020 16:30

I'd there were any performance impacts they would be very minimal at best.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.