473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Programmatically populate grid

Is it possible to populate a grid using code (not binding it to a
datasource). Is there something like an additem method?

Thanks,

Oct 6 '06 #1
2 3175
Tim,

No, there isn't. You need to find a class that implements IList and
then bind to that.

DataSet classes are disconnected data, meaning that you don't need a
database in order to use them. They also have designer support, so you
should just use that in your program and bind to that (populating that
programatically).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tim Kelley" <tk*****@company.comwrote in message
news:uT**************@TK2MSFTNGP02.phx.gbl...
Is it possible to populate a grid using code (not binding it to a
datasource). Is there something like an additem method?

Thanks,

Oct 6 '06 #2
I gave that a try. I created my dataset and datatable and populated it
with the data I need.
I bound the dataviewgrid to the dataset, but no records show in my grid. I
have checked the datatable and there are actually records in the table. Am
I missing something? Here is the code I am using:

DataSet dsgrid = new DataSet();

DataTable workTable = new DataTable();

dsgrid.Tables.Add("tablename");

workTable.Columns.Add("field1", typeof(String));

workTable.Columns.Add("field2", typeof(String));

workTable.Columns.Add("field3", typeof(String));

code to populate table

dataGridView1.DataSource = dsgrid.Tables[0];
Thanks,
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:%2****************@TK2MSFTNGP02.phx.gbl...
Tim,

No, there isn't. You need to find a class that implements IList and
then bind to that.

DataSet classes are disconnected data, meaning that you don't need a
database in order to use them. They also have designer support, so you
should just use that in your program and bind to that (populating that
programatically).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tim Kelley" <tk*****@company.comwrote in message
news:uT**************@TK2MSFTNGP02.phx.gbl...
>Is it possible to populate a grid using code (not binding it to a
datasource). Is there something like an additem method?

Thanks,


Oct 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Viktor Zadro | last post by:
When populate grid with data from dataset: 1. Public Sub New().. Or 2. Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
9
by: Mike L | last post by:
I tried a sample of code in MSDN magazine, but now I'm stuck. What code has the best performance to populate a Data Grid with a SP? Below is the code I have, which might be completing the wrong...
4
by: Mike L | last post by:
I'm open for any suggestions on how to better program this. I want the user to select a license from a combo box, cboPrivilege and then the user will click the add button, then a record will be...
0
by: Monika Mesik | last post by:
I have made some progress toward creating very straight-forward UI for editing a non-hierarchical list of data without implementing a DataGrid. The UI needs to present the data for editing in...
4
by: Girish | last post by:
Im trying to create a grid within a grid programmatically. Ive been successful in doing this but I need the embedded grid to fire its ItemDataBound event so I can handle it. The event does not seem...
4
by: Vasantha peddireddy | last post by:
I am posting a page to another page (form post). The data grid on the second page is being populated with data. Now, on page load of the second page, I would like to send the grid data on this page...
3
by: Gina_Marano | last post by:
Hey All, Working with the .Net data has been the hardest part of my transition. It just doesn't seem very intuitive. I want to have a master/detail relationship between 2 grids. When the...
2
by: John Straumann | last post by:
Hello all: I am trying to populate a GridView with data being read from a call to a web service. I have seen plenty of examples that simply execute a SQL data reader, set the Grid data source to...
1
by: 111111222222 | last post by:
Hi All, As of now I am populating grid view using code behind. I want to place a textbox and a button to search the grid view using TIN which is one column in my grid view. I placed the textbox...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.