Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to populate details gridview from master gridview?

Posted on 2008-10-27
8
Medium Priority
?
339 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 400 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

879 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