473,396 Members | 1,852 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,396 software developers and data experts.

Store datagridview values into a dataset

Hi,

I want to store the values from the datagridview into a dataset and use the dataset as a method parameter.. However, the datagridview is not bind to any source..

I tried something like the one below but it won't work. Is there a way to do something like this?

DataSet ds = new DataSet();
ds = (DataSet) dgv.DataSource;

Thanks..
Oct 6 '08 #1
5 2540
nateraaaa
663 Expert 512MB
How are you loading data into your datagridview? Please post the code you are using.

Nathan
Oct 6 '08 #2
How are you loading data into your datagridview? Please post the code you are using.

Nathan

The data are being entered manually by the user.. The datagridview only has 8columns/6rows, no more, no less.. The datagridview is used to get the calibration data from the user based on the actual readings from the calibration equipments.

Thanks....
-Jan
Oct 7 '08 #3
nateraaaa
663 Expert 512MB
The data are being entered manually by the user.. The datagridview only has 8columns/6rows, no more, no less.. The datagridview is used to get the calibration data from the user based on the actual readings from the calibration equipments.

Thanks....
-Jan
Sounds like you need to create a datatable and then programmatically create DataRows for your table based on the information entered by the user. You can then add the datatable to a dataset if you want or you could just reference the datatable directly.

Nathan
Oct 7 '08 #4
Sounds like you need to create a datatable and then programmatically create DataRows for your table based on the information entered by the user. You can then add the datatable to a dataset if you want or you could just reference the datatable directly.

Nathan
I did something like this:

private DataTable _dtBLT = new DataTable();

Form_Load Event()
BindingSource bsBLT = new BindingSource();
for (int i = 0; i < 6; i++)
{
DataRow rowBLT = _dtBLT.NewRow();
_dtBLT.Rows.Add(rowBLT);
}
bsBLT.DataSource = _dtBLT;
dgvBLT.DataSource = bsBLT;

After the user entered the data in the datagridview, how will I store those values into the datatable? Can you provide some sample codes please?

Thanks.
Jan
Oct 8 '08 #5
nateraaaa
663 Expert 512MB
I did something like this:

private DataTable _dtBLT = new DataTable();

Form_Load Event()
BindingSource bsBLT = new BindingSource();
for (int i = 0; i < 6; i++)
{
DataRow rowBLT = _dtBLT.NewRow();
_dtBLT.Rows.Add(rowBLT);
}
bsBLT.DataSource = _dtBLT;
dgvBLT.DataSource = bsBLT;

After the user entered the data in the datagridview, how will I store those values into the datatable? Can you provide some sample codes please?

Thanks.
Jan
You are on the right track. You need to create DataColumns for _dtBLT. After you have done that you can create the datarow and then assign a value from the datagridview to each column in each row. Check out the link below for code examples:
http://www.eggheadcafe.com/community/aspnet/2/10044227/c--just-a-comment--bin.aspx

Nathan
Oct 9 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: c j anderson, mcp | last post by:
Core Question: Is there a better way to dynamically pull the allowed values of an attribute out of a dataset's schema. I have an XML file that contains a string element with two attributes,...
4
by: Chris Botha | last post by:
VS2005 and I have a DataTable displayed in a DataGridView that needs custom sorting, with the DataSource of the grid set to the DataTable and the SortCompare event just won't fire. Then I found...
3
by: joey.powell | last post by:
I have a datagridview where I set its "DataSource" property to a DataSet and its "DataMember" property to a table within the DataSet. I need for the DataGridView to "sort" through the contents of...
2
by: Rick Shaw | last post by:
Hi, I have a problem with the datagridview not refreshed when the application first appear on the screen. The datagridview display data from a table in the dataset. At the same time, I've added...
0
by: schoultzy | last post by:
Hello Everyone, I have been trying to figure this one out for two days now. I have created a DataGridView which is populated by an ObjectDataSource. My problem occurs when I attempt to use the...
5
by: DanThMan | last post by:
The situation: * I have a ButtonColumn in a DataGridView. * When the user preses one of the buttons, a dialog appears. * Based on what the user selects in the dialog, data is entered...
7
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is...
1
by: Freddy Coal | last post by:
Hi, I'm newbye in that theme. I would like put the data of a dBase in a DataGridView, why make that?. I'm open my database with this instructions: '---------------- Dim Tabla As New...
3
by: Marco Pais | last post by:
Hi there. I have a DataGridView on a desktop application and it's being filled through the use of a Web Service, wich returns a DataSet. The I use datagrid.DataSource=mydataset.tables to bind...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
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...
0
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,...

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.