Results 1 to 3 of 3

Thread: (Option) Join 2 Gridviews with seperate droplist.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Posts
    332

    (Option) Join 2 Gridviews with seperate droplist.

    Hello all,
    I have a page with two gridviews. Both gridviews request a user to select from a droplist that ask the server for the data. The drop list are the exact same but are not linked.

    However, I would like to provide the user the option to request both gridviews to populate based on 1 comon request/selection. My idea is to add a check box that will link the two droplist thus having the gridviews pass different request for the same subject name.

    See the link and it may make more sense.

    http://visualboxscore.com/cfb/boxscores.aspx


    See the next post for the code I am using.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2007
    Posts
    332

    Re: (Option) Join 2 Gridviews with seperate droplist.

    In order to make it fit I had to remove some of the formatting code.

    <asp: DropDownList ID="DropDownList1" DataSourceID="SqlDataSource2" AutoPostBack="true"
    DataTextField="team" runat="server" />
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" SelectCommand="SELECT DISTINCT [team] FROM [cfb_master_boxscore] ORDER BY [team]"
    ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" />
    <br />
    <table>
    <tr>
    <td valign="top" width="1250PX">
    <asp:GridView ID="GridView1" AllowSorting="True" AllowPaging="false" runat="server" GridLines="Both"
    DataSourceID="SqlDataSource1" DataKeyNames="date" Width="1250PX"
    AutoGenerateColumns="false" OnDataBound="GridView1_DataBound"
    SkinID="booksSkin">
    <Columns>
    <asp:BoundField HeaderText="Date" DataField="date" DataFormatString="{0:MM/dd/yy}" ItemStyle-Width="4%" SortExpression="date" />
    <asp:BoundField HeaderText="RushNo" DataField="rush_no" ItemStyle-Width="5%" SortExpression="rush_no" />
    <asp:BoundField HeaderText="RushNet" DataField="rush_net" ItemStyle-Width="5%" SortExpression="rush_net" />
    <asp:BoundField HeaderText="YPC" DataField="yds_per_carry" ItemStyle-Width="3%" SortExpression="yds_per_carry" />
    <asp:BoundField HeaderText="PassAtt." DataField="pass_att" ItemStyle-Width="5%" SortExpression="pass_att" />
    <asp:BoundField HeaderText="PassYds" DataField="pass_yds" ItemStyle-Width="5%" SortExpression="pass_yds" />
    <asp:BoundField HeaderText="YPA" DataField="yds_per_att" ItemStyle-Width="3%" SortExpression="yds_per_att" />
    <asp:BoundField HeaderText="Plays" DataField="total_plays" ItemStyle-Width="4%" SortExpression="total_plays" />
    <asp:BoundField HeaderText="Yards" DataField="total_yds" ItemStyle-Width="4%" SortExpression="total_yds" />
    <asp:BoundField HeaderText="YPP" DataField="yds_per_play" ItemStyle-Width="3%" SortExpression="yds_per_play" />
    <asp:BoundField HeaderText="TurnOver" DataField="turnover_margin" ItemStyle-Width="4%" SortExpression="turnover_margin" />
    <asp:BoundField HeaderText="APY" DataField="allpurpose_yds" ItemStyle-Width="3%" SortExpression="allpurpose_yds" />
    <asp:BoundField HeaderText="Score" DataField="pts" ItemStyle-Width="4%" SortExpression="pts" />
    <asp:BoundField HeaderText="Result" DataField="result" ItemStyle-Width="4%" SortExpression="result" />
    <asp:BoundField HeaderText="Opponent" DataField="opponent" ItemStyle-Width="9%" ItemStyle-HorizontalAlign="Center"/>
    <asp:BoundField HeaderText="DTalent" DataField="opp_def_talent" ItemStyle-Width="4%" SortExpression="opp_def_talent" />
    <asp:BoundField HeaderText="DAPY" DataField="opp_def_allpurpose_yards" ItemStyle-Width="3%" SortExpression="opp_def_allpurpose_yards" />
    <asp:BoundField HeaderText="DScore" DataField="opp_def_pts" ItemStyle-Width="4%" SortExpression="opp_def_pts" />
    <asp:BoundField HeaderText="DTotalYds" DataField="opp_def_total_yds" ItemStyle-Width="5%" SortExpression="opp_def_total_yds" />
    <asp:BoundField HeaderText="DYPP" DataField="opp_def_yds_per_play" ItemStyle-Width="3%" SortExpression="opp_def_yds_per_play" />
    <asp:BoundField HeaderText="DRushNet" DataField="opp_def_rush_net" ItemStyle-Width="5%" SortExpression="opp_def_rush_net" />
    <asp:BoundField HeaderText="DYPC" DataField="opp_def_yards_per_carry" ItemStyle-Width="3%" SortExpression="opp_def_yards_per_carry" />
    <asp:BoundField HeaderText="DPassYds" DataField="opp_def_pass_yds" ItemStyle-Width="5%" SortExpression="opp_def_pass_yds" />
    <asp:BoundField HeaderText="DYPA" DataField="opp_def_yds_per_att" ItemStyle-Width="3%" SortExpression="opp_def_yds_per_att" />
    </Columns>
    </asp:GridView>
    <b>OFFENSIVE SUMMARY:</b>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT [date], [result], [opponent], [rush_no], [rush_net], [yds_per_carry], [pass_att], [pass_yds], [yds_per_att], [total_plays], [total_yds], [yds_per_play], [turnover_margin], [allpurpose_yds], [pts], [team],[opp_def_talent],[opp_def_allpurpose_yards], [opp_def_pts], [opp_def_total_yds], [opp_def_yds_per_play], [opp_def_rush_net], [opp_def_yards_per_carry], [opp_def_pass_yds], [opp_def_yds_per_att] FROM [cfb_master_boxscore] WHERE ([team] = @team)ORDER BY [date]"
    ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>">
    <SelectParameters>
    <asp:ControlParameter ControlID="DropDownList1" Name="team" PropertyName="SelectedValue"
    Type="String" />
    </SelectParameters>
    </asp:SqlDataSource>
    </table>
    </div>

    <asp: DropDownList ID="DropDownList2" DataSourceID="SqlDataSource4" AutoPostBack="true"
    DataTextField="team" runat="server" />
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" SelectCommand="SELECT DISTINCT [team] FROM [cfb_master_boxscore] ORDER BY [team]"
    ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" />
    <br />
    <table>
    <tr>
    <td valign="top">
    <asp:GridView ID="GridView2" AllowSorting="True" AllowPaging="false" runat="server" GridLines="Both"
    DataSourceID="SqlDataSource3" DataKeyNames="date" Width="1250PX"
    AutoGenerateColumns="false" OnDataBound="GridView2_DataBound"
    SkinID="booksSkin">
    <Columns>
    <asp:BoundField HeaderText="Date" DataField="date" DataFormatString="{0:MM/dd/yy}" ItemStyle-Width="4%" SortExpression="date" />
    <asp:BoundField HeaderText="RushNo" DataField="def_rush_no" ItemStyle-Width="5%" SortExpression="def_rush_no" />
    <asp:BoundField HeaderText="RushNet" DataField="def_rush_net" ItemStyle-Width="5%" SortExpression="def_rush_net" />
    <asp:BoundField HeaderText="YPC" DataField="def_yds_per_carry" ItemStyle-Width="3%" SortExpression="def_yds_per_carry" />
    <asp:BoundField HeaderText="PassAtt." DataField="def_pass_att" ItemStyle-Width="5%" SortExpression="def_pass_att" />
    <asp:BoundField HeaderText="PassYds" DataField="def_pass_yds" ItemStyle-Width="5%" SortExpression="def_pass_yds" />
    <asp:BoundField HeaderText="YPA" DataField="def_yds_per_att" ItemStyle-Width="3%" SortExpression="def_yds_per_att" />
    <asp:BoundField HeaderText="Plays" DataField="def_total_plays" ItemStyle-Width="4%" SortExpression="def_total_plays" />
    <asp:BoundField HeaderText="Yards" DataField="def_total_yds" ItemStyle-Width="4%" SortExpression="def_total_yds" />
    <asp:BoundField HeaderText="YPP" DataField="def_yds_per_play" ItemStyle-Width="3%" SortExpression="def_yds_per_play" />
    <asp:BoundField HeaderText="TurnOver" DataField="turnover_margin" ItemStyle-Width="4%" SortExpression="turnover_margin" />
    <asp:BoundField HeaderText="APY" DataField="def_allpurpose_yds" ItemStyle-Width="3%" SortExpression="def_allpurpose_yds" />
    <asp:BoundField HeaderText="Score" DataField="def_pts" ItemStyle-Width="4%" SortExpression="def_pts" />
    <asp:BoundField HeaderText="Result" DataField="result" ItemStyle-Width="4%" SortExpression="result" />
    <asp:BoundField HeaderText="Opponent" DataField="opponent" ItemStyle-Width="4%" SortExpression="opponent" />
    <asp:BoundField HeaderText="OTalent" DataField="opp_off_talent" ItemStyle-Width="4%" SortExpression="opp_off_talent" />
    <asp:BoundField HeaderText="OAPY" DataField="opp_off_allpurpose_yards" ItemStyle-Width="3%" SortExpression="opp_off_allpurpose_yards" />
    <asp:BoundField HeaderText="OScore" DataField="opp_off_pts" ItemStyle-Width="4%" SortExpression="opp_off_pts" />
    <asp:BoundField HeaderText="OTotalYds" DataField="opp_off_total_yds" ItemStyle-Width="5%" SortExpression="opp_off_total_yds" />
    <asp:BoundField HeaderText="OYPP" DataField="opp_off_yds_per_play" ItemStyle-Width="3%" SortExpression="opp_off_yds_per_play" />
    <asp:BoundField HeaderText="ORushNet" DataField="opp_off_rush_net" ItemStyle-Width="5%" SortExpression="opp_off_rush_net" />
    <asp:BoundField HeaderText="OYPC" DataField="opp_off_yards_per_carry" ItemStyle-Width="3%" SortExpression="opp_off_yards_per_carry" />
    <asp:BoundField HeaderText="OPassYds" DataField="opp_off_pass_yds" ItemStyle-Width="5%" SortExpression="opp_off_pass_yds" />
    <asp:BoundField HeaderText="OYPA" DataField="opp_off_yds_per_att" ItemStyle-Width="3%" SortExpression="opp_off_yds_per_att" />
    </Columns>
    </asp:GridView>
    <b>DEFENSIVE SUMMARY:</b>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" SelectCommand="SELECT [date], [result], [opponent], [def_rush_no], [def_rush_net], [def_yds_per_carry], [def_pass_att], [def_pass_yds], [def_yds_per_att], [def_total_plays], [def_total_yds], [def_yds_per_play], [turnover_margin], [def_allpurpose_yds], [def_pts], [team], [opp_off_talent], [opp_off_allpurpose_yards], [opp_off_pts], [opp_off_total_yds], [opp_off_yds_per_play], [opp_off_rush_net], [opp_off_yards_per_carry], [opp_off_pass_yds], [opp_off_yds_per_att] FROM [cfb_master_boxscore] WHERE ([team] = @team)ORDER BY [date]"
    ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>">
    <SelectParameters>
    <asp:ControlParameter ControlID="DropDownList2" Name="team" PropertyName="SelectedValue"
    Type="String" />
    </SelectParameters>
    </asp:SqlDataSource>
    </table>
    </div>
    </asp:Content>

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: (Option) Join 2 Gridviews with seperate droplist.

    Use [code] tags to format your code. It's unreadable without proper formatting.

    Currently, your page does an autopostback whenever the selected index of the dropdownlist control changes. The user doesn't have a chance of specifying 'both'. You can do this in several ways. You can disable the autopostback and have a checkbox (apply to both) and button next to the dropdownlists. You then handle the button click event and if the checkbox is checked, you know what to do. That's just one way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width