My application have two tables,I want to display both tables data on single Gridview
And update ,delete that data
Is this Possible? How?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
PankaJ DPosted Jan 2, 2011, 11:41 PM
qmaster-> id(pk), que,op1,op2,op3,op4,asn,status
qdetails -> id(fk),qtype,qtechonoly,level
I want to update , delete both table data on single gridview , or suggest me onother option.
Sam HobbsPosted Jan 2, 2011, 2:48 PM
Is there a one-for-one correspondence of records in both tables? If not, then is one table used like a lookup table that does not get updated? If there is the same number of records, then are you updating data in both tables? This last question probably is not important but it is best to answer it anyway.
Subhendu DePosted Jan 2, 2011, 5:12 AM
Step 1 -> you populate DataTable1(DT1)
Step 2 -> you populate DataTable2(DT2)
Step 3 -> Join these two tables and create DataTable3(DT3).
Step 4 -> Suggest you to create one extra column(col1) in both the tables(DT1 & DT2) that will contain the tablename in the DT3.
Step 5 -> Bind DT3 with gridview and make col1 invisible.
Step 6 -> Add EditCommand & DeleteCommand to the gridview.
Step 7 -> For EditCommand & DeleCommand event handler, you have access to the column col1 from which you can build the sql and execute it.
I didn't try it but it seems it will work. If you find any difficulties to implement it, let me know. I will definitely help you out.