locked
Filling dropdowns with data from stored procedure RRS feed

  • Question

  • New to SP 2010 coding. I want to fill multiple dropdowns on one page in SP with data from multiple stored procedures. How would I go about that for SP 2010 using VS 2010? I can establish a data source in SP, but am not sure how to reference it in code. Would I want to create an application page or a visual web part?
    Friday, July 8, 2011 7:20 PM

Answers

  • Another simple approach might be (if you don't want to use BCS), create Data Access Layer/Repository using Entity Framework or Enterprise Library, to read data from database as DTO objects. Then bind the DTO objects in dropdown. One simple code might be:

     

    ProductRepository productRepository=new ProductRepository();
    var products=productRepository.GetAllProducts();
    ddlProducts.DataSource=products;
    ...
    



    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com
    • Proposed as answer by pavel.gz Tuesday, July 12, 2011 7:55 AM
    • Marked as answer by Shimin Huang Friday, July 22, 2011 9:02 AM
    Sunday, July 10, 2011 8:52 AM

All replies