473,657 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programmaticall y 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 3190
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.co m

"Tim Kelley" <tk*****@compan y.comwrote in message
news:uT******** ******@TK2MSFTN GP02.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.A dd("tablename") ;

workTable.Colum ns.Add("field1" , typeof(String)) ;

workTable.Colum ns.Add("field2" , typeof(String)) ;

workTable.Colum ns.Add("field3" , typeof(String)) ;

code to populate table

dataGridView1.D ataSource = dsgrid.Tables[0];
Thanks,
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:%2******** ********@TK2MSF TNGP02.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.co m

"Tim Kelley" <tk*****@compan y.comwrote in message
news:uT******** ******@TK2MSFTN GP02.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
237
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
3315
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 way to populate a data grid. I like using code and not the server explorer. (I replaced the sa password for this post.) private void frmDealerSearch_Load(object sender, System.EventArgs e) { string sConnString = "Data
4
2999
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 added to the data grid. My current code is coming up with errors, dt and drv are unknown in the else part of the if statement. if (this.dgPrivileges.DataSource == null) {
0
976
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 textboxes, drop-down lists, check boxes, and radio buttons. ASP.NET Validation controls need to be part of this UI as well. I arranged the editing controls in a user control which I then placed in the ItemTemplate of a DataList control. I got the...
4
4477
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 to fire for some reason. The code is below. Look towards the end of the CustomerDataGrid_OnItemDataBound(object sender, DataGridItemEventArgs e) method. This is where I register the event and place the programmatically created grid into the...
4
2321
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 to the first page and populate the grid on the first page with the same data on second page. Please let me know how can I do this. Thanks, Vasantha
3
2951
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 user navigates grid 1, only the details for that record appear in grid 2. How? I created a datasource and added the 2 tables. The relationship
2
6389
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 the reader, and then call DataBind(), but I cannot seem to figure out how to build the GridView row by row with anything except text. I need the 2nd column of the Grid to be a hyperlink or a button, and this is where I am having an issue. I can...
1
2794
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 and button on top of grid view. Please send the process or code to do this... I am new to programming field. Your help will be greatly appreciated. Thanks
0
8823
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8730
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.