Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to populate details gridview from master gridview?

Posted on 2008-10-27
8
Medium Priority
?
338 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 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
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 Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

721 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