This is a migrated thread and some comments may be shown as answers.

Binding Data to a Basic HTML Table

1 Answer 62 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
EVP
Top achievements
Rank 2
EVP asked on 29 Sep 2014, 01:45 AM
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,

Eric

1 Answer, 1 is accepted

Sort by
0
Accepted
Doroteya
Telerik team
answered on 02 Oct 2014, 08:59 AM
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.


Regards,
Doroteya
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
Getting Started
Asked by
EVP
Top achievements
Rank 2
Answers by
Doroteya
Telerik team
Share this question
or