Solved

How to populate details gridview from master gridview?

Posted on 2008-10-27
8
333 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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ā€¦
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

777 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