Solved

How to populate details gridview from master gridview?

Posted on 2008-10-27
8
325 Views
Last Modified: 2012-05-05
I have a master gridview with a list of clinics and i have a details gridview that will list invoices. I want to link the two gridviews together. I have a select button for the master gridview. By clicking on the select button I want to populate the details gridview with the clinic record from the master gridview that I've just selected. I would like to know how this can be accomplished?
Example.aspx.txt
Example.cs.txt
0
Comment
Question by:mjoseph23
  • 4
  • 3
8 Comments
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 100 total points
ID: 22814117
to be frank i havent seen your code
but mu recommendation will be to quite simple
on the selectedindexchanged (means row changed on the parent grid) set the row filter of the invoices data table to the id of the clinic and then rebind it
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22814201
suggestion,
in the details datasource, add a  SelectParameters asp:ControlParameter linked to your master gridview<s SelectedDataKey property.
jsut make sure to call DataBind on the details gridview when a item is selected on the master grid view
0
 

Author Comment

by:mjoseph23
ID: 22814954
I opted to do the second option. I am getting an error with the bind of my datakeys. the select statement works fine in oracle. here is my code.


<asp:SqlDataSource ID="sdsInvoicesGv" runat="server" ProviderName="System.Data.OracleClient"

                            ConnectionString="<%$ AppSettings:ConnectString %>" SelectCommand="SELECT DISTINCT * FROM (SELECT tblinvoices.tblcontract_id, tblinvoices.tblclinic_id, tblclinic.NAME, tblinvoices.invoice_number, tblinvoices.payment_date, tblinvoices.payment, vw_current_balance.current_balance, vw_total_paid.total_paid FROM tblInvoices, tblClinic, tblContract, tblClinics, vw_current_balance, vw_total_paid                      WHERE ( (tblclinics.tblcontract_id = tblcontract.ID) AND (tblinvoices.tblcontract_id = tblclinics.tblcontract_id) AND (tblclinics.tblclinic_id = tblclinic.ID) AND (tblinvoices.tblclinic_id = tblclinics.tblclinic_id) AND (vw_current_balance.tblcontract_id = tblinvoices.tblcontract_id) AND (vw_current_balance.tblclinic_id = tblinvoices.tblclinic_id) AND (vw_total_paid.tblcontract_id = tblinvoices.tblcontract_id) AND (vw_total_paid.tblclinic_id = tblinvoices.tblclinic_id) AND (vw_current_balance.invoice_number = tblinvoices.invoice_number) AND (vw_total_paid.invoice_number = tblinvoices.invoice_number) ) ORDER BY tblinvoices.tblcontract_id, tblinvoices.tblclinic_id, tblinvoices.payment_date, tblinvoices.invoice_number ) WHERE tblcontract.id = :TBLCONTRACT_ID AND tblclinic_id = :TBLCLINIC_ID ORDER BY tblclinic_id, payment_date">

<SelectParameters>

<asp:ControlParameter Name="TBLCONTRACT_ID" ControlID="gvClinics" Type="Int32" PropertyName="" />

<asp:ControlParameter Name="TBLCLINIC_ID" ControlID="gvClinics" Type="Int32" PropertyName="" />

                            </SelectParameters>

                        </asp:SqlDataSource>

Open in new window

0
 

Author Comment

by:mjoseph23
ID: 22814984
oops i posted the wrong code. here is exactly how i have it.
<asp:SqlDataSource ID="sdsInvoicesGv" runat="server" ProviderName="System.Data.OracleClient"

                            ConnectionString="<%$ AppSettings:ConnectString %>" SelectCommand="SELECT DISTINCT * FROM (SELECT tblinvoices.tblcontract_id, tblinvoices.tblclinic_id, tblclinic.NAME, 

                            tblinvoices.invoice_number, tblinvoices.payment_date, tblinvoices.payment, vw_current_balance.current_balance, vw_total_paid.total_paid 

                            FROM tblInvoices, tblClinic, tblContract, tblClinics, vw_current_balance, vw_total_paid 

                            WHERE ( (tblclinics.tblcontract_id = tblcontract.ID) AND (tblinvoices.tblcontract_id = tblclinics.tblcontract_id) 

                            AND (tblclinics.tblclinic_id = tblclinic.ID) AND (tblinvoices.tblclinic_id = tblclinics.tblclinic_id) 

                            AND (vw_current_balance.tblcontract_id = tblinvoices.tblcontract_id) AND (vw_current_balance.tblclinic_id = tblinvoices.tblclinic_id) 

                            AND (vw_total_paid.tblcontract_id = tblinvoices.tblcontract_id) AND (vw_total_paid.tblclinic_id = tblinvoices.tblclinic_id) 

                            AND (vw_current_balance.invoice_number = tblinvoices.invoice_number) AND (vw_total_paid.invoice_number = tblinvoices.invoice_number) ) 

                            ORDER BY tblinvoices.tblcontract_id, tblinvoices.tblclinic_id, tblinvoices.payment_date, tblinvoices.invoice_number 

                            ) WHERE tblcontract.id = :TBLCONTRACT_ID AND tblclinic_id = :TBLCLINIC_ID ORDER BY tblclinic_id, payment_date">

                            <SelectParameters>

                                <asp:ControlParameter Name="TBLCONTRACT_ID" ControlID="gvClinics" Type="Int32" PropertyName='SelectedDataKey["TBLCONTRACT_ID"]' />

                                <asp:ControlParameter Name="TBLCLINIC_ID" ControlID="gvClinics" Type="Int32" PropertyName='SelectedDataKey["TBLCLINIC_ID"]' />

                            </SelectParameters>

                        </asp:SqlDataSource>

Open in new window

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 18

Accepted Solution

by:
David Robitaille earned 400 total points
ID: 22814994
PropertyName is the propery of the gvClinics
So try with  PropertyName="SelectedDataKey "
and i dont think it will work with 2 parameter, you chould find a way to get the parameter or set them "maunally" (witout using a control parameter but a normal parameter)
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22815011
better with taht code, but i still think the problem is with the PropertyName
what if you try SelectedDataKey("TBLCLINIC_ID")
[] --> ()
0
 

Author Comment

by:mjoseph23
ID: 22815358
ok i got it working without the contract id.
<asp:ControlParameter Name="TBLCLINIC_ID" ControlID="gvClinics" PropertyName="SelectedDataKey[1]" />
i will figure out how to do it with contract id later. i want to know how do i repopulate when row changes. is it the following code?
0
 
LVL 18

Expert Comment

by:David Robitaille
ID: 22815375
yup, that should work
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now