Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2006, 05:47 AM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid + datatable

Hi

I have a datatable which contains all the information which i need to display on a form. Now, i want to associate the datatable with a datagrid and display. Iam using the below code to do the same. Some how, i dont know the below code is not working the form is appearing with no data visible..its a blank form.
            DataGrid display_grid = new DataGrid();
            display_grid.DataSource = [datatablenamehere];
            display_grid.DataMember = "Firstname";
            display_grid.Show();
Can any body please help.Early reply is much appreciated.

Thanks!
Edukulla

 
Old September 4th, 2006, 12:23 PM
Authorized User
 
Join Date: Sep 2006
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
   If ur datasource is Dataset then u are required to provide the datamember .Because The Dataset may contain more than one table.But Here u are using DataTable .So No need to set datamamber property.

Also if its webform(ASP.NET) ,U must call control's databind method or page's databind method.

eg. page.databind()

 
Old September 11th, 2006, 04:53 PM
Authorized User
 
Join Date: Jul 2004
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
Default

In winforms you shouldn't need to create a new instnace of the grid. Simply drag and drop it onto the form or panel. The other thing is that the DataSource is any object that implements IEnumerable. This includes but is not limited to the List<T> collection, DataSet, DataTable, etc.

SriRamaKrishna is correct though, if this is an ASP.Net application, you should call the DataBind() method of the display_grid object as well. however, i would not recommend calling the Page.DataBind() method as that will persist to all controls on the page and would likely be an unneeded performance hit.

Hope this helps,


www.CoderForRent.com
Get A Computer Job!

www.ComputersComplete.com
Computer Parts & Accessories





Similar Threads
Thread Thread Starter Forum Replies Last Post
Datatable Limno .NET Framework 1.x 0 May 28th, 2008 02:37 PM
Problem with DataTable ayazhoda ASP.NET 1.x and 2.0 Application Design 1 April 8th, 2007 10:12 PM
DataTable from DataGrid.DataSource Jamal Junior ASP.NET 2.0 Basics 1 March 24th, 2006 01:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.