gridview select to open dependent formviews

Posted on 2009-05-18
Last Modified: 2013-12-17
I've to a page that loads a gridview with a select option per row. The row has ids that are related to mulitple tables. i want to select the row and populate multiple formviews.

I've got it to work with the 1st formview but the 2nd won't load,i can run my query and it pulls back data.


formview1 is based on the picid and it works
formview2 is based on the sicid and it will not load. This is basically the same as picid just a different table and data.
Any suggestions?

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 

            CellPadding="4" DataKeyNames="ReqId" DataSourceID="SqlDataSource1" 

            ForeColor="#333333" GridLines="None" AllowPaging="True" 



            onpageindexchanged="GridView1_PageIndexChanged" >

            <RowStyle BackColor="#EFF3FB" />


                <asp:CommandField ShowSelectButton="True" />

                    <asp:BoundField DataField="picId" HeaderText="Pic Id" 

                    Visible="true" />

                    <asp:BoundField DataField="sicid" HeaderText="Sic Id" 

                    SortExpression="sicid" Visible="true" />

                <asp:BoundField DataField="ServiceDate" HeaderText="Service Date" 

                    SortExpression="ServiceDate" />

                 <asp:BoundField DataField="Priority" HeaderText="Priority" 

                    SortExpression="Priority" />

                <asp:BoundField DataField="ReqId" HeaderText="ReqId" 

                    InsertVisible="False" ReadOnly="True" SortExpression="ReqId" Visible="false" />


            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />

            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />

            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

            <EditRowStyle BackColor="#2461BF" />

            <AlternatingRowStyle BackColor="White" />


        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 

            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 

            SelectCommand="SELECT [ReqId], [picid], [sicid], [ServiceDate], [Priority]  FROM [ReqInformation] WHERE ([UserId] = @UserId)">


                <asp:ProfileParameter Name="UserId" PropertyName="SelectedCustomerId" Type="String" />



        <asp:FormView ID="FormView1" runat="server" 

            DataKeyNames="picid" DataSourceID="SqlDataSource2"

            Width="75%" BorderColor="#99CCFF" BorderStyle="None" >


 <table cellpadding="0" cellspacing="0" class="style1" style="background-color:#EFF3FB;border-color:#B5C7DE;border-width:1px;border-style:Solid;border-collapse:collapse;">


            <td align="center" style="color:White;background-color:#507CD1;font-size:0.9em;font-weight:bold;">




                <td >

                 <asp:Label ID="picidLabel" runat="server" Text='<%# Eval("picid") %>' Visible="true" />

                <asp:Label ID="patFNameLabel" runat="server" Text='<%# Bind("patFName") %>' /> <asp:Label ID="patLNameLabel" runat="server" Text='<%# Bind("patLName") %>' />






        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 

            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 

            SelectCommand="SELECT * from picinformation WHERE ([picid] = @picid)"> 


                <asp:ControlParameter ControlID="GridView1" Name="picid" 

                    PropertyName="SelectedValue" Type="Int32" />



        <asp:FormView ID="FormView2" runat="server" 

        DataKeyNames="sicid" DataSourceID="SqlDataSource3"

        Width="75%" BorderColor="#99CCFF" BorderStyle="None" >



                <asp:Label ID="sicidLabel" runat="server" Text='<%# Eval("sicid") %>' />

                <br />


                <asp:Label ID="sicFNameLabel" runat="server" Text='<%# Bind("sicFName") %>' />

                <br />


                <asp:Label ID="sicLNameLabel" runat="server" Text='<%# Bind("sicLName") %>' />



        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 

            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 

            SelectCommand="SELECT * FROM [sicInformation] WHERE ([sicid] = @sicid)">


                <asp:ControlParameter ControlID="GridView1" Name="sicid" 

                    PropertyName="SelectedValue" Type="Int32" />



Open in new window

Question by:fwstealer
  • 2
  • 2
LVL 12

Expert Comment

ID: 24417118

You have braces [  ] around this did you mean that?


Accepted Solution

fwstealer earned 0 total points
ID: 24422945
i figured it out - used a left outer join -duh
LVL 12

Expert Comment

ID: 24472598
Can you clarify your answer?

Author Comment

ID: 24475644
i had to change the sql to allow for a left outer join and that worked perfectly.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 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

7 Experts available now in Live!

Get 1:1 Help Now