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

filling columns in grid on user input event

hi friends..i am using a grid view with one of its column as combobox.
now what i want is that when user select some option from the combobox then some of the cells only in the same row get filled automatically according to the selected option.

like if there are 4 fields in grid : emp_id , name , age , salary
and id column is of type combobox then on selecting the particular emp_id from the list , its coressponding name get displayed in the same row and then user can enter the other fields.similarlly when the emp_id get selected in the 2nd row of grid then 2nd row column "name" get filled.


how could i achieve this?
Apr 7 '10 #1

✓ answered by Frinavale

Well, if you bind a GridView to an empty data source then the GridView will not display on the screen (there's nothing to display).

So you need to create a data source that contains "empty" rows. To do this you could create a table and then add a few rows that contain "spaces" so that the table (being used as the data source) contains data but is "empty".

-Frinny

9 3317
Frinavale
9,735 Expert Mod 8TB
A GridView is an ASP.NET control however a ComboBox is a desktop application control. What type of application are you developing? An ASP.NET application or a Windows Desktop application?

-Frinny
Apr 13 '10 #2
@Frinavale
hi Frinavale..I am using Visual studio 2005 and developing a databse windows application in vb.net with SQL server2005 as database.

I want to bit elaborate my point.what my requirement is that my user have to create bill of items.Now some times item may be one & some time it may be more.
if there are 4 fields for the input for each item: item_no , item_name, qunatity,price
item_no is a combobox , and other are normal type in grid.
there is "master" table in database with fields :item_no , item_name
now i populate the combobox with item_no.On selection of a particular item the item_name in the grid should be filled automatically according to "master" table.Now user will enter "qty" and "price".he may repeat the process for other item if he wants to create a bill for those also.
All the data in the grid should be saved to a table with name "bill" which has 6 colmns : bill_no , bill date, item_no, item_name,qty,price.
here it is noticable that "bill_no" and "bill_date" will come from the same form but are not enterd in the grid.i mean they will be same for the whole bill form.
Apr 14 '10 #3
Frinavale
9,735 Expert Mod 8TB
Quick overview:
  • You have populated your DataGridView
  • You have a ComboBox as one column in the DataGridView
  • You want to retrieve the selected item in the ComboBox when the selected index changes so that you can populate something else

I'm not sure what specifically you're having problems with so I'll guess here.
I'm assuming that you do not know how to get the selected item in the ComboBox... if that's the case then you should probably look over this article: DataGridViewComboBoxEditingControl Class. It explains how to use the ComboBox in the DataGridView.

-Frinny
Apr 14 '10 #4
@Frinavale
hi frinvale...actually my problem is not ony limited to populating other column according to the selection of combobox in grid.What i exactly want is that there should be an empty grid every time and we can enter the info
I dont want to edit/display old records
Apr 15 '10 #5
Frinavale
9,735 Expert Mod 8TB
I see.

In that case create a table with empty rows (they contain spaces or something) in it and bind to that :)


-Frinny
Apr 15 '10 #6
@Frinavale
nice reply...bt i m nt getting u :-p .could u plz elaborate ur pint
Apr 16 '10 #7
Frinavale
9,735 Expert Mod 8TB
Well, if you bind a GridView to an empty data source then the GridView will not display on the screen (there's nothing to display).

So you need to create a data source that contains "empty" rows. To do this you could create a table and then add a few rows that contain "spaces" so that the table (being used as the data source) contains data but is "empty".

-Frinny
Apr 16 '10 #8
@Frinavale
thnx friend....actually i had alredy solved this problem..infact the solution is the same as suggested by you.i had not bound the grid to any source.as there is one combobox in the grid when i select an item from the combobx and then I click to enter something in next cell to it in the same row then system gives an runtym error " System.FormatException :Value cann't be converted to type 'System.String' "
Apr 17 '10 #9
the value in combobx is of type tinyint(SQL)
Apr 17 '10 #10

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

Similar topics

2
by: CW | last post by:
In an earlier thread, I was asking for help on "Invalid attempt to FieldCount when reader is closed" error when I was using a dataset rather than a datareader to bind to a datagrid. After...
0
by: javatopia | last post by:
I am creating a data grid's columns on the fly in my web page. The Bind operation works just fine, and data is displayed correctly when I change the layout of the grid (add/remove columns). I...
8
by: pmud | last post by:
Hi, I have 2 questions: 1. I have an editable data grid with 21 columns. I need to edit only 2 cloumns in this data grid. But when the grid is displayed in Edit mode, all the columns show long...
1
by: thegame | last post by:
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls Hello, I have an interesting dilemma. I have an ASPX page with two user controls (two ASCXs). ...
5
by: Gary Blakely | last post by:
I'm giving this post another try - it can't be too difficult for everyone.... In the program below, the web page has dataGrid1. the only thing that has been done to it at design time is to...
0
by: Jennifer | last post by:
I'm trying to fill a datagrid on a VB ASP web page. No data is showing up on my grid and I'm not sure why. The code is as follows Dim dvMain As DataView Dim X As Int16 Dim dtMain As New...
1
by: Hugh Barnett | last post by:
I am using Visual Studio to create a VB .NET application to run on Windows 2000. I am trying to display data from a Sybase ASA table in a form, allow the user to update the data in the form, and...
0
by: Nigpig | last post by:
Hi I have a datagrid with button columns that about 1 in 4 times fails to completely fill the columns. When this happens the rest of the page is not completed but terminates rendering after the...
0
by: bappelsin | last post by:
Hello, I have a problem with the datagridview. I have a view with around 25 different columns. To make life easier for the users I have implemented a popup dialog where the user can select which...
12
by: ab12 | last post by:
I'm trying to write a program in C that gets a shape outlined with asterisks from the user, and returns that shape filled with asterisks. It will also get the coordinates of a point inside the shape...
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
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: 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?
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.