Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

Iam using datagridview to add multiple details.i have number of coloumns in gridview like product code ,product name,qty,rate,total etc
when i type product code in the row below 'product code' column corresponding product name should come automatically in the next column
how will i get that corresponding pdt name.I dont want db code instead i want front end code .How to get those values.

Thanks in advance
Amrutha
Posted
Comments
jai000 25-Jan-12 6:21am    
Where do you have product information? Do you have product information in DataTable or in any other form?
amritha444 25-Jan-12 6:32am    
I DONT WANT ANY DB CODE TO RETRIEVE PRODUCT INFORMATION WHEN I TYPE PRODUCT CODE IN FIRST COLUMN CORRESPONDING PRODUCT NAME SHOULD COME IN THE NEXT COLOUMN .WHERE TO WRITE CODE FOR THE SAME IN CELL_LEAVE EVENT OR SOMTHING LIKE THAT? HOW TO GET EACH CELL ID.
lukeer 25-Jan-12 7:46am    
Your shift key is jamming.
You certainly did not write all uppercase by intention, because doing so would be considered shouting and therefore rude.

There is a link called "Improve question" at the bottom of every question. Use that if you want to provide more information on your problem.

1 solution

hi,

It can be done in 2 ways.

Method 1:
Get the corresponding data from DB on click of the text box grid view.
Which might be slow.

or

Method 2:
1.Get the dataset from the db.
2.Store it as a datatable.
3.After you enter the product code ,
i) call a method that accepts the text as parameter.
ii)search the corresponding product name in the datatable like
datatable.select(YOUR QUERY) .
iii)Return the product name
4.display the product name returned in the textbox in grid.


Example of datatable select
// Create a table of five different people.
	// ... Store their size and sex.
	DataTable table = new DataTable("Players");
	table.Columns.Add(new DataColumn("Size", typeof(int)));
	table.Columns.Add(new DataColumn("Sex", typeof(char)));

	table.Rows.Add(100, 'f');
	table.Rows.Add(235, 'f');
	table.Rows.Add(250, 'm');
	table.Rows.Add(310, 'm');
	table.Rows.Add(150, 'm');

	// Search for people above a certain size.
	// ... Require certain sex.
	DataRow[] result = table.Select("Size >= 230 AND Sex = 'm'");

Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900