Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm using vs2005 and sql server 2005.
Im having two tables in my database which were employee and dept
In both the tables EmplId is common field and have relationship
Now, in asp.net im displaying two grids,
1. Employee
2.Dept
The functionality is if we click emplid on first gird
the columns of dept table should be displayed in 2nd grid.

when we click the Emplid in 1st grid it should display a message that
we are selecting the following emplId:

Next in second it should be edit and update after editing and update it should
display message that the respective id has been updated.

Next we have a button to insert,it appears out side the grids, i.e AddNewRecord
when we click the button a row should inserted into 2nd grid.

I want description In which events we should write the code

Could any one please help me

Thanks in Advance.
Posted
Updated 21-Jun-11 21:09pm
v3

when you select the empid from the first grid on the base of this empid fliter the data from the second grid on selectedindexchange event of first gridview try this i hope its will work.



you want insert into row in gridview then add filed in Footer and insert if any problem in insert data update me i will send u code for insert row.
 
Share this answer
 
v2
hello

use This
Fully functional Nested DataGrid[^]

or
Editable Nested DataGrid[^]

thanks

Sanjeev
 
Share this answer
 
v2
You can get the Employee Id by using this code

VB
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
    MsgBox(DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value)
End Sub


After getting your empID you can get the data from database and add it to other Grid

Thanks
 
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