473,385 Members | 2,269 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,385 software developers and data experts.

Empty a Datagrid

I just started working with C#.
I have a combobox where upon selecting a product a grid is displayed in the
form with a bunch of data. When selecting another product, I get an
exception because the datagrid is not empty.

How do I empty a Datagrid.

Thanks, Imad.
Nov 15 '05 #1
1 4565
Imad, what you need to do is use databinding in the form, and let the
data binding automatically show each product's data from the combo.
This is what's called a "Master-detail" view, in which the "master" is
a product in the combo, and a "detail" for each product is displayed
in the datagrid.
THere are a lot of ways to do this, but here's an article that will
get you started:
http://weblogs.asp.net/rosherove/story/9088.aspx
(Lesson 4 explains how to make a combo box act as a "master")

good luck.
--Roy Osherove
www.iserializable.com

On Tue, 4 Nov 2003 16:16:21 -0500, "Imad Belabbes"
<ib*******@hotmail.com> wrote:
I just started working with C#.
I have a combobox where upon selecting a product a grid is displayed in the
form with a bunch of data. When selecting another product, I get an
exception because the datagrid is not empty.

How do I empty a Datagrid.

Thanks, Imad.


Nov 15 '05 #2

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

Similar topics

2
by: Jim | last post by:
In my Win App, I have a datagrid that's bound to a dataset. When the form loads, the datagrid fills. How can I add an empty row to the end of the datagrid during a button click (similar to...
7
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
1
by: Reza | last post by:
Hi I have a column in my datagrid that can have values of null at times. I am not assigning any value to it, if it is coming from Database empty. Now, the problem is I guess the datetime variables...
3
by: Baren | last post by:
Hi! I am developing a web project using ASP.NET and VB.NET as code behind. In one page the user attaches files to the list. The same data is shown in the and the max records visible is 4. Now...
2
by: carballosa | last post by:
Hi guys, I need to use a one row datagrid in my asp.net 1.1 application. The data source will contain 1 or 0 entries. When no rows of data are present I want to show an empty row in the datagrid...
7
by: Neo Geshel | last post by:
Greetings. I have a serious problem. I have multiple sets of tables, several of which are chained more than two tables deep. That is, I have a parent, a child, and a great-grandchild table. ...
22
by: EMW | last post by:
Hi, I managed to create a SQL server database and a table in it. The table is empty and that brings me to my next chalenge: How can I get the info in the table in the dataset to go in an empty...
2
by: Lucas Tam | last post by:
Hello, I am trying to update a datagrid via an async call, but the datagrid shows up empty. I've checked the datatable - there are indeed rows in it... Here is my code:
1
by: lgalumbres | last post by:
Hi, I have a datagrid on Winform that is bound to a datatable. In essence, what I would like to do is that when a user inputs a number into a textbox control for example 5 then 5 empty rows...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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,...

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.