Any possible to use SQL Query to load data from custom table for Data source of Drop-down list?

David Yu asked on April 6, 2018 03:06

We need get Drop-down list data source dynamically. Want to find a solution

Correct Answer

Peter Mogilnitski answered on April 6, 2018 04:54

If understand correctly, what you need is:

  1. Define new query for custom table
  2. Create your custom query according to guidelines. It should be something similar to:

    SELECT CustomTableIdFieldName, CustomTableValueFieldName FROM customtable_sampleTable WHERE ##WHERE## ORDER BY ##ORDERBY##

  3. Add New Query Data Source to your page template and point it to your query

  4. Add basic repeater to generate your drop down, point it your query data source.
  5. Define a transformation that your repeater that will use. <option value="<%# Eval("CustomTableIdFieldName") %>">Eval("CustomTableValueFieldName")</option>

  6. Add <select></select> tags to content before and after of your repeater

Your repeater now should render a drop down :)

P.S. There is also a shorter way without defining query, you can use custom table repeater. You can find the example under /Examples/Web-parts/Custom-tables/Custom-table-repeater.aspx on Corporate Site exmample. You just need to define transformation and add <select> to content before and after

1 votesVote for this answer Unmark Correct answer

Recent Answers


Hasan Shah answered on April 6, 2018 10:32

most of the web development service providers use the basic HTML and use Image Text

0 votesVote for this answer Mark as a Correct answer

Sobia Waqar answered on June 4, 2018 12:11

We usually use this sql query in our ERP Software in Pakistan, and its work fine for us.

0 votesVote for this answer Mark as a Correct answer

Alex Brian answered on June 26, 2018 20:34

It usually use it on my WPX Hosting Promotional Blog as well. which you can generally find it here https://www.accountingweb.com/profile/wp-coupons

0 votesVote for this answer Mark as a Correct answer

Alex Brian answered on June 26, 2018 20:37

You can also check out this post on HostGator Coupon Code 75% OFF! https://www.spreaker.com/user/10580438

0 votesVote for this answer Mark as a Correct answer

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