<a href="http://www.micropoll.com/akira/mpview/585320-168921">Click Here for Poll</a><a href="http://www.questionpro.com" title="online surveys">Online Survey</a><BR> | <a href="http://www.micropoll.com" title="Website Polls">Website Polls</a><BR> | <BR><a href="http://www.micropoll.com/akira/MicroPoll?mode=html&id=168921">View MicroPoll</A></div>

Visual Studio 2010!

Read now >

Windows Mobile Development Thoughts

Read now >

View Now
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.
ADVERTISEMENT
ADVERTISEMENT

 

DevSource.com: Your Source for Visual Studio on Facebook
ADVERTISEMENT
Editing and Displaying Data with the New ASP.NET 2.0 GridView Control
By Jeff Cogswell

Rate This Article: Add This Article To:

Editing and Displaying Data with the New ASP.NET 2.0 GridView Control - ' Creating the '
( 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.



 
 
>>> More Using Microsoft Visual Studio Articles          >>> More By Jeff Cogswell