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

Datagrid with dropdowns

In a dataview, I have lots and lots of table relations that make editing
each row kind of a hassle... having to look up ID numbers in 7 different
tables to reference the correct items in the parent tables. And then, once
entered, it's almost impossible to read.

Is there a way to have each field that has a relationship to a table display
the possible choices in a dropdown list? That would be most useful.

Apr 13 '07 #1
1 1313
On Apr 13, 12:21 am, "Peter" <star...@hotmail.comwrote:
In a dataview, I have lots and lots of table relations that make editing
each row kind of a hassle... having to look up ID numbers in 7 different
tables to reference the correct items in the parent tables. And then, once
entered, it's almost impossible to read.

Is there a way to have each field that has a relationship to a table display
the possible choices in a dropdown list? That would be most useful.
To get you started:

1) Create a DataGridView object and set it to NOT automatically
generate the columns: AutoGenerateColumns = false

2) Create a DataGridViewComboBoxColumn object...
Set it's DataSource to the table of "valid values" (child table)...
Set its DisplayMember property to the column name in that table of the
description that you want to see in the drop down...
Set its ValueMember property to the primary key column name or (other
column that represents the foreign key in the parent table column)...
Set the DataPropertyName to the name of the column in the parent table
that corresponds to the ValueMember column in the combo box (this is
the parent column that you want to update with the combo selections).

3) Add the combo box column to the data grid

4) Set the DataSource of the data grid view to the parent table

Now instead of seeing arbitrary primary key integers in your columns
you will see that the combo boxes show the proper descriptions and can
be used to update the foreign key integers in the parent table.

Opinion: it is always better to turn off auto column generation with
the DGV, leaving it on will cause the grid to throw many data bind
complete events as you add combo boxes and have to then remove the
auto generated text boxes for the same FK columns. Auto generate is
really, IMO just for RAD prototyping, as once your code starts to
listen to more and more grid events auto generation causes a lot of
"thrashing" that gets complicated to handle. I find it best to
manually add my own custom columns based on the columns collection of
the underlying data source at object construction time.

HTH
Rick
Apr 13 '07 #2

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

Similar topics

1
by: Deepa | last post by:
I am working on a web page which has a datagrid to be populated. The problem is I need to get the data from 2 different tables to bind the 2 columns of the datagrid. I am not sure of how to do...
0
by: Marc Miller | last post by:
Hi to all, (I apologize that I posted this in dotnet.languages.vb.controls, but I NEED and answer quickly, please) I have an 'employees' datagrid which contains company numbers as labels....
8
by: Sue | last post by:
I have a datagrid populated with 6 visible read-only labels and several hidden fields. Below the datagrid, I have a table with various textboxes, dropdowns, etc. I've managed to decypher the...
0
by: Jeffrey | last post by:
Hi... I have several dropdowns located in a datagrid footer. Now say i modify the selection in dropdown1. I want to refresh the content of the other dropdowns with the result of a database...
7
by: DJ Dev | last post by:
Hi All, I have a complex problem. I have dropdownlists (usually 3-5) and the user selects some value from these and for each value selected, datagrids are shown to the user. I am creating the...
0
by: Jim Bancroft | last post by:
Hi everyone, I'm using a DataGrid on one of my web pages and within it I have an ItemTemplate containing a DropDownList. The relevant section looks like this: <asp:datagrid id="DataGrid1"...
2
by: Jim Bancroft | last post by:
This may be a no-brainer, but I'm sure I follow what's happening here... I have a DataGrid with one DropDownList per row. If I select a few DropDown items and postback my page, I can't loop...
5
by: I am Sam | last post by:
I have a rather complicated problem I need to sort out and wonder if anyone can assist me. The ingredients: Two DropDownList Controls One DataGrid Purpose of Page:
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
5
by: Me LK | last post by:
I need to add a line to choose a size into a dropdown . Since I have the dropdown nested inside a datagrid this is not working.When a page displays there are several rows of dropdowns but only the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
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...
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...

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.