Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 6th, 2006, 05:47 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
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

  #2 (permalink)  
Old September 4th, 2006, 12:23 PM
Authorized User
 
Join Date: Sep 2006
Location: , , India.
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()

  #3 (permalink)  
Old September 11th, 2006, 04:53 PM
Authorized User
 
Join Date: Jul 2004
Location: , , .
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
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:39 AM.


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