Solved

How to populate details gridview from master gridview?

Posted on 2008-10-27
8
337 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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
 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Suggested Courses

623 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