Ver Mensaje Individual
  #6 (permalink)  
Antiguo 20/08/2013, 12:58
Avatar de gokufast
gokufast
 
Fecha de Ingreso: abril-2007
Mensajes: 540
Antigüedad: 17 años
Puntos: 3
Respuesta: elegir una opcion de un DropDownList y aparezca el GridView Correspondient

Lo solucione y aca esta el codigo
WebForm1.aspx
Código HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>

<body>
    <form id="form1" runat="server">
    <asp:sqldatasource ID="Sqldatasource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PUBSConnectionString %>" 
        SelectCommand="SELECT [pub_id], [pub_name] FROM [publishers]"></asp:sqldatasource>
    <div>
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            DataSourceID="Sqldatasource1" DataTextField="pub_name" DataValueField="pub_id" 
            onselectedindexchanged="Page_Load" ontextchanged="Page_Load">
        </asp:DropDownList>
        <br />
        <br />
        <br />
        <asp:Label ID="lblDropDownSelected" runat="server" Text="Label"></asp:Label>
        <br />
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:PUBSConnectionString %>" 
            onselecting="SqlDataSource2_Selecting" 
            SelectCommand="SELECT [pub_id], [title], [price], [pubdate] FROM [titles] WHERE ([pub_id] = @pub_id)">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="pub_id" 
                    PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
    </div>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource2">
        <Columns>
            <asp:BoundField DataField="pub_id" HeaderText="pub_id" 
                SortExpression="pub_id" />
            <asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
            <asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
            <asp:BoundField DataField="pubdate" HeaderText="pubdate" 
                SortExpression="pubdate" />
        </Columns>
    </asp:GridView>
    </form>
</body>
</html> 
WebForm1.aspx.cs
Código C#:
Ver original
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7.  
  8. namespace WebApplication4
  9. {
  10.     public partial class WebForm1 : System.Web.UI.Page
  11.     {
  12.         protected void Page_Load(object sender, EventArgs e)
  13.         {
  14.             lblDropDownSelected.Text = DropDownList1.SelectedValue;
  15.         }
  16.     }
  17. }