2006-01-18
| Table of Contents: |
| Rate This Article: | Add This Article To: |
( Page 4 of 6 )
GridView">
Creating the GridView
Now, the moment you've been waiting for! All that business about the data source was just leading up to this.
Go ahead and drop a GridView on your form. Open the control's Smart Tag, and select its data source as SqlDataSourc1, as shown in Figure 8.
When you select the data source, you'll get a few more options on the Smart Tag. Check the "Enable Sorting" checkbox, the "Enable Editing" checkbox, and the "Enable Deleting" checkbox. Be forewarned: the grid gets wider when you check these, and the crazy Smart Tag moves to the right! Sometimes I feel the world move beneath my feet.
The next thing I'm going to have you do is set up the columns. For a couple of the columns I'm going to show you how you can format them in different ways. And with the last column I'll show you how you can put images in the grid.
In the Smart Tag, click Edit Columns. This opens the Fields dialog box, shown in Figure 9.
The box in the upper left corner lists the different types of columns that you can put in a GridView control. The BoundField type is simply a column in the GridView that's attached to a column in the table being read.
As you can imagine, the CheckboxField puts a checkbox in each row of the given column; the HyperLinkField puts a link in each row of the given column; and Button puts a button. The CommandField you already used; when you selected the Enable Editing and other checkboxes, you were creating CommandField columns. The TemplateField is for building more complex columns.
I don't have enough room here to go through all of these, but I'll show you a few. I encourage you to go on and dig through the different types of columns and play with them and see how they work.
![]() |
|


