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

Need DataGrid Help

I have a form with a comboBox and a datagrid. When I select an ID from the comboBox it will display a particular item with that ID on the datagrid. I would like know how I can create a new row everytime I select an ID from the comboBox. For example, right now when I select an ID it just replaces the row I already have instead of creating a new one...I know it has to be somewhere in the line of:
Expand|Select|Wrap|Line Numbers
  1.  if (this.comboBox1.SelectedIndexChanged = true)
  2. then Create New Row...
Can anyone help me? I'd really appreciate the help, maybe someone has tried this already.
Jun 16 '08 #1
4 816
Plater
7,872 Expert 4TB
Assign a DataTable as your DataSource for the DataGrid.
Then when you select an item in the combobox, add a new row to that datatable. It will then appear in the DataGrid.
Jun 16 '08 #2
For solving this problem you can use binding list.
ComboBox_SelectedIndexChanged event use this binding list with data grid binder to bind the data at runtime to the datagrid. This will add the new row in the data grid, without disturbing the previous rows. But do not clear the binding list.
Jun 18 '08 #3
Hey, thanks for the input. What I did instead was create a table with an invoice number that i generate and add 1 in a function. What i do is save the invoice number on the table with all the data and then at the end display all the data for that particular Invoice number on the datagrid. It isn't very simple but it works great since i don't display anything on the datagrid until the different items have been saved in the database then just simply display all the data with that number.
Jun 20 '08 #4
cloud255
427 Expert 256MB
The code for adding a row to a datagrid at runtime:

Expand|Select|Wrap|Line Numbers
  1. datagridName.rows.add(new object[] {ColumnValue1, ColumnValue2, ... });
this will add a single row to the datagrid at the bottom of all the rows
Jun 23 '08 #5

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

Similar topics

2
by: Roel | last post by:
I need help to format the column and detect any change on the datagrid. My source code is: dim da as SqlDataAdapter dim ds as DataSet dim dtSource as DataTable dim conn as SQLConnection =...
11
by: Junkguy | last post by:
I need some help programmatically causing a row in a DataGrid to "flush" its contents to its bound data (in Visual Studio 6 using Windows Forms with C#). My issue is I want to send an update to...
0
by: MrNobody | last post by:
I am desperately in need of some help to get a summary row for my DataGrid. A summary row is just a row always on the bottom which has totals for certain columns. I have been able to find...
1
by: ericm1155 | last post by:
I am trying to display some information from a database in a form that displays one record per line. When the user clicks anywhere on a line, that record is highlighted and selected, and my program...
1
by: Gidi | last post by:
Hi, I'm looking for a way to do something, and i need help on finding the best way to do it. I've one Form that contains a dataGrid, and one of the buttons in that form, opens another Form...
7
by: Joe | last post by:
Hi, I’m new to asp.net. I want to create an asp.net page that allows user to edit the data. I have pasted my code below. I am able to display the data in a datagrid. At the bottom of the page...
1
by: Anna | last post by:
I have a simple DataGrid that displays a list of characteristics and allows you to edit a description for each characteristic. The query that feeds this involves a join, as the characteristics and...
10
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain...
21
by: coleenholley | last post by:
I've been trying since last Friday to get an answer on how to get a SPECIFIC row.cell value from a datagrid. I've had plenty of suggestions, but nothing works to get the value from a SPECIFIC Row...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.