Cita:
Iniciado por RootK
Salu2
Soy principiante en ASP .NET y tengo un codigo para obtener la informacion contenida en un DropDownList1 y luego colocarla en un textbox pero necesito colocar el primer elemento en blanco este es mi codigo en la pagina
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="Id_AreaEsc" DataValueField="Id_AreaEsc" OnSelectedIndexChanged="DropDownList1_TextChanged" AutoPostBack="True">
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SABEConnectionString %>"
SelectCommand="SELECT * FROM [CatAreaEscolar]"></asp:SqlDataSource>
y mi codigo en C# para obtener los datos es :
protected void DropDownList1_TextChanged(object sender, EventArgs e)
{
int listindex;
DataView dv = (DataView)SqlDataSource1.Select(new DataSourceSelectArguments());
DataTable dt = dv.ToTable();
listindex = (int)this.DropDownList1.SelectedIndex;
DataRow dr = dt.Rows[listindex];
TextBox2.Text = dr["Alias"].ToString();
TextBox1.Text = dr["Descripcion"].ToString();
}
Gracias espero que me puedan ayudar