Tutorial RSS
 
DB Tutorials Server Intellect Cloud Hosting
Navigator: Home - Display - Displaying Data Using Controls in Visual Studio

Displaying Data Using Controls in Visual Studio

In this tutorial we will cover adding controls to the page to display data and applying it to a pre-existing database table.


Displaying Data Using Controls in Visual Studio

Download the Data Control Project Source

 

In this tutorial we will cover adding controls to the page to display data and applying it to a pre-existing database table. If you do not already have a table with data created and the LiqDataSource control configured please see the Configuring a LinqDataSource Control tutorial to learn how to create this file or download the Configuring a LinqDataSource Control source file from the last tutorial.

 

Yes, it is possible to find a good web host. Sometimes it takes a while. After trying several, we went with Server Intellect and have been very happy. They are the most professional, customer service friendly and technically knowledgeable host we've found so far.

 

-We want to display data on the page from our database using the LinqDataSource control.  There are a few different tools we can use to do this depending on how we want our data structured. If we want the data to appear on the page in a list format, we would use the ListView control. If we want the data to appear as a form we would use the formview and so on.  There are three controls that can be used with the LinqDataSource Control.  They are DetailsView, FormView, and GridView. 

 

1. If you don’t have the source file for this tutorial you can download it here.  Open the website in Visual Studio 2010 or Visual Web Developer Express, and open the deafault.aspx page.

2. Switch to design view and make sure the LinqDataSource control is on the page.

3. In the Toolbox under the Data menu, click on a DetailsView control and drag it onto the page.

4. In the DetailsView task menu click on the dropdown menu and select LinqDataSource1 as the data source for the control. (see image below)


                    

We are using Server Intellect and have found that by far, they are the most friendly, responsive, and knowledgeable support team we've ever dealt with! 

 

5. Save and then debug or run the application.

-When the browser loads you should see a very basic web table.  The table displays the information in our database but it is very limited.  There is more than one line of data in our database but we can’t access anything but is already visible. 

6. Close the browser and return to Visual Studio.  You can experiment with the other two View controls (FormView and GridView) by just deleting the current control on the page (right click the control and select delete) and reconfiguring the new control by repeating step 4.

7. When you have finished experimenting with the controls, make sure a control (any of the three is fine) is on the page and the data source has been configured.

8. Open the LinqDataSource tasks menu on the LinqDataSource control and check the Enable Delete, Enable Insert and Enable Update boxes.

9. Open the task menu on the View control and check the Enable Paging, Enable Inserting, Enable Editing and Enable Deleting boxes. (See the image below)



                   

 

10. Save and then debug or run the application again.

-As you will notice, there are some new options that are available on the table. Please note that these controls will not work because we have not created the event handlers in the code behind.  This is simply just to show you the functionality of the controls. The paging feature lets us navigate to view each page of data currently stored in the database. The last thing we will look at it is the Auto formatting options that are available to us in the task menu.  The auto formatting feature lets us select pre styled pages to easily change the appearance of the tables.

 

11. When you are finished viewing the application, close the web browser to return to Visual Studio.

12. Click on the task menu tab to open the view control task menu and click the auto format link.

13. When the auto format menu opens, select a scheme from the menu on the left and then click Apply (See image below). 



                        
  



-When you are finished viewing the application, close the web browser to return to Visual Studio.

 

Yes, it is possible to find a good web host. Sometimes it takes a while. After trying several, we went with Server Intellect and have been very happy. They are the most professional, customer service friendly and technically knowledgeable host we've found so far.