Binding Data to a Basic HTML Table

2 posts, 1 answers
  1. EVP
    EVP avatar
    8 posts
    Member since:
    Jul 2013

    Posted 28 Sep 2014 Link to this post

    Hi there,
              This may seem like a fairly simple question, but I am just starting out with DataAccess and haven't found any documentation on what I am trying to accomplish. Running an ASP.NET Application, I wish to query a domain model and display it's results in a table. However, I want to be able to design the table myself using my own CSS & HTML. I don't want to use any of your UI controls, which is the only thing you provide documentation on.

    For the sake of this post, lets say I have a method called when the page loads, which does the following:

    using (HorizonEntitiesModel dbContext = new HorizonEntitiesModel())
                    IEnumerable<Production> productions = dbContext.Productions.Where(c => c.Company_id_link == "1");

    Now, within the ASP.NET page markup, how can I integrate the ListView or Repeater, and bind specific fields from this collection, to the page?

    Thanks in advance,

  2. Answer
    Doroteya avatar
    497 posts

    Posted 02 Oct 2014 Link to this post

    Hi Eric,

    Attached to this message, you can find a sample that shows the binding of a repeater to a query executed through Telerik Data Access in the backend of the page, and a listview bound to OpenAccessLinqDataSource. Both the repeater and the listview utilize plain tables to display the data. The two binding approaches can be used together, as well as separately - as alternatives. Either way, the end result allows you to style the content according to your needs. You can find the workflow for running the sample at the end of this post.

    The idea for the repeater is to implement its templates providing the overview for the table, which will be displayed in it. This approach involves entirely manual typing of HTML code. On the backend side, the repeater will be bound to your query. 

    The idea for the listview is to bind it to a customized query executed through OpenAccessLinqDataSource (no need for composing the queries yourself) and to use the Configure ListView dialogue to automatically implement one of the predefined layouts. Note that although the implementation is generated automatically, you can still provide your custom styling for the table.

    Additionally, the sample demonstrates one of the recommended by Telerik Data Access approaches for handling the instances of the context in a web scenario.

    How to run the sample:
    1. Make sure you have an instance of SQL Server (Express) at your disposal.
    2. Create the SofiaCarRental sample database on the server.
    3. Extract the .zip file on a convenient place.
    4. Open the solution in Visual Studio.
    5. Edit the App.config file in the model project, and the Web.config file in the web app project, to provide the name of the machine that hosts SQL Server, and the name of the server instance.
    6. Upgrade the Data Access references as described here.
    7. Set the web app project as a startup project.
    8. Press F5 for a test.

    I hope this helps. If you need further information, do not hesitate to get back to us.

    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
  3. DevCraft banner
Back to Top