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

x
?
Solved

gridview select to open dependent formviews

Posted on 2009-05-18
4
Medium Priority
?
596 Views
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.

Gridview1
rowid
picid
sicid
reqid

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" 
            AllowSorting="True" 
            OnSelectedIndexChanged="GridView1_SelectedIndexChanged" 
            onpageindexchanged="GridView1_PageIndexChanged" >
            <RowStyle BackColor="#EFF3FB" />
            <Columns>
                <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" />
            </Columns>
            <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:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT [ReqId], [picid], [sicid], [ServiceDate], [Priority]  FROM [ReqInformation] WHERE ([UserId] = @UserId)">
            <SelectParameters>
                <asp:ProfileParameter Name="UserId" PropertyName="SelectedCustomerId" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
 
        <asp:FormView ID="FormView1" runat="server" 
            DataKeyNames="picid" DataSourceID="SqlDataSource2"
            Width="75%" BorderColor="#99CCFF" BorderStyle="None" >
            <ItemTemplate>
 <table cellpadding="0" cellspacing="0" class="style1" style="background-color:#EFF3FB;border-color:#B5C7DE;border-width:1px;border-style:Solid;border-collapse:collapse;">
            <tr>
            <td align="center" style="color:White;background-color:#507CD1;font-size:0.9em;font-weight:bold;">
            Patient</td>
            </tr>
            <tr>
                <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") %>' />
	 </td>
              </tr>
</table>
            </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT * from picinformation WHERE ([picid] = @picid)"> 
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="picid" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
 
        <asp:FormView ID="FormView2" runat="server" 
        DataKeyNames="sicid" DataSourceID="SqlDataSource3"
        Width="75%" BorderColor="#99CCFF" BorderStyle="None" >
            <ItemTemplate>
                sicid:
                <asp:Label ID="sicidLabel" runat="server" Text='<%# Eval("sicid") %>' />
                <br />
                sicFName:
                <asp:Label ID="sicFNameLabel" runat="server" Text='<%# Bind("sicFName") %>' />
                <br />
                sicLName:
                <asp:Label ID="sicLNameLabel" runat="server" Text='<%# Bind("sicLName") %>' />
            </ItemTemplate>
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand="SELECT * FROM [sicInformation] WHERE ([sicid] = @sicid)">
            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="sicid" 
                    PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>

Open in new window

0
Comment
Question by:fwstealer
[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
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24417118
[sicInformation]

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

0
 

Accepted Solution

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

Expert Comment

by:williamcampbell
ID: 24472598
Can you clarify your answer?
0
 

Author Comment

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

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