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 originalusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication4
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblDropDownSelected.Text = DropDownList1.SelectedValue;
}
}
}