Home > Microsoft .Net Development Tips > C# Development > Create a DataGrid using a DataView as the source
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

C# DEVELOPMENT

Create a DataGrid using a DataView as the source


Melvin Lervick
04.07.2003
Rating: -2.33- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This tip was submitted to the VS.NET Info Center by member Melvin Lervick. Please let other users know how useful it is by rating it below. Do you have an interesting .NET time-saver, troubleshooting technique, shortcut or code snippet of your own you'd like to share? Submit it here.


This tip explains how to use DataView with a DataGrid and access individual fields using text field, checkboxes, etc., on the form outside the DataGrid.

Here is the sample that creates a DataGrid using a DataView as the source for the grid. The initial sample is VB.NET. Some of the internal code snippets are C# .NET. I did this on purpose to emphasize that language should not be the driving factor for a project or example. If you can't use or at least read both, you need to get out the books.

Everything to this point is pretty straightforward and reasonably well documented. After a row is selected in the DataGrid, the objective is to populate standard fields on the form for editing purposes. (Note: The fields in the G...


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
.NET Framework database programming best practices
Windows 7 for developers
Microsoft's Oslo modeling platform, the M language and .NET
Using the Visual Studio 2005 DataSet Designer to build a data access layer
Windows Developments: Product news February 2008
Oracle updates data access components for Visual Studio 2008
Reporting tool now supports Word 2007 and VS 2008
Windows Developments: Product news, January 2008
Choose the right .NET data provider, optimize application performance
Windows Developments: Product news, December 2007
The fallacy of the data layer -- or, a new architectural model for software designs

Visual Basic and Visual Basic .NET
Compose XML more quickly using Visual Basic 9
Virtualization keeps Legacy Apps alive
VB 9 Anonymous Types help create flexible objects
Visual Studio Team System Add-ins: Conchango Scrum for Team System and Scrum Dashboard
Book Excerpt: Sams Teach Yourself Visual Basic 2008 in 24 Hours -- Complete Starter Kit
Check out CodePlex for a ton of interesting .NET projects
Book excerpt: Murach's VB 2008
Book excerpt: Printing in Visual Basic 2005
Visual Basic 2008 and closures
WinForms development using SQL Server 2005 and Visual Basic 2005

C# Development
Let Microsoft StyleCop tame your wild C#
Picking a .NET smart client communications technology
LINQ beyond queries: Strong-typed refection
Book excerpt: An introduction to DSL tools
Assembly versioning in the .NET Framework 2.0
Book excerpt: Creating graphical output using the .NET Compact Framework
On Extension Methods in C# and .NET Framework 3.5
Generate RSA public and private keys, export to XML
Book excerpt: Upgrading to Visual Studio 2005
Learning .NET: Tips for getting started with .NET development

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


RID were set to ReadOnly.) How you access the individual row and its fields is NOT well documented. The .NET environment defines DATAVIEWS, DATAROWVIEWS, CURRENCYMANAGER and a number of other objects that can be used, but there are very few examples. After a tedious search of the online help, I decided that the CurrencyManager could be used to define DataRowView.

Individual fields can now be accessed using the following:

What isn't obvious is the most straightforward way to access the Row and Field.

It is really too bad that there are no good examples of how to define and use DataGrids. The DataGrid could be used by a lot more people if there were examples that described the HOW TO. I've found that once you know how to use DataViews and DataGrids, it is pretty easy. The LEARNING CURVE is very long though. I'm sure many of us give up before we ever really get proficient using the DataGrid. There are also a lot of things that I still do not know how to do, so if you have readers who have learned HOW TO, you could create an entire book on the information that they have acquired.

Rate this Tip
To rate tips, you must be a member of SearchWinDevelopment.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts