Two Tables Of Columns In One Grid View One Table Data Followed Another Table Data

Posted by Srinivas673 under ASP.NET on 3/10/2011 | Points: 10 | Views : 6403 | Status : [Member] | Replies : 4
I have One RadioButtonList It Consists Of 3 Chocies 1.All 2.Account Notes 3.Transaction Notes

i Have Two Tables Two Tables Have 4 Columns
When I select All From Radio Button List DIaply Two Tables Of Data in GridView With 4 coluns One Table Data By Another table Data
When I select AccountNotes From Radio Button List First Table Data In Grid View
When I select Transaction Notes From Radio Button List Second Table Data In Grid View

I Have To take Only One Grid View




Responses

Posted by: T.saravanan on: 3/10/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Refer this code...

All Condition..
Select A.*,B.* from Table1 A inner join Table 2 on A.Id = B.Id

Account Condition...
Select * from Table1

Transaction Condition...
Select * from Table2


Using the above queries to get the values in DataSet...Based on the Selection shown the data in your GridView..
If First Selection...
GridView1.DataSource = ds.Tables[0].Copy();

GridView1.DataBind();


Note: If you done in front end means its not possible (i.e:Table1 & Table2 have different no.of records).


If you Combine both table value means using Merge Method...

Ex:
DataTable dt1 => Table 1 Value

DataTable dt2 => Table 2 Value
dt1.Merge(dt2);


Note: If you want 4 Columns means Assign both Table Column Name are same in DataTable.

Try this...

Thanks,
T.Saravanan

Srinivas673, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 3/11/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Srinivas673

i think u want write code on RadioButtonList1_SelectedIndexChanged event . . and fill the gridview based on different condition . . with database table


Best Regard's
Prabhakar

Srinivas673, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 3/11/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
This you can do in the stored proc side only where you need to handle based on radio button selection.

Note: Make sure the datatypes of the four columns in both the tables be same.

Thanks and Regards
Madhu

Srinivas673, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/11/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Your requirement is bit confusing... can you please brief it

Thanks
Karthik
www.f5Debug.net

Srinivas673, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response