Foros del Web » Programación para mayores de 30 ;) » .NET »

Por Favor Ayuda urgente con un Dropdownlist !!!

Estas en el tema de Por Favor Ayuda urgente con un Dropdownlist !!! en el foro de .NET en Foros del Web. Hola soy nueva programando en .NET espero y alguien me puede ayudar y gracias de antemano!! Mi duda es la siguiente tengo un Dropdownlist el ...
  #1 (permalink)  
Antiguo 07/01/2008, 14:24
 
Fecha de Ingreso: enero-2008
Mensajes: 4
Antigüedad: 16 años, 3 meses
Puntos: 0
Por Favor Ayuda urgente con un Dropdownlist !!!

Hola soy nueva programando en .NET espero y alguien me puede ayudar y gracias de antemano!!

Mi duda es la siguiente tengo un Dropdownlist el cual lleno con el siguiente codigo:

Dim dsDatos As New DataSet
Dim daDatos As New SqlDataAdapter("select * from Tab_Proveedores", sqlConeccion)
daDatos.Fill(dsDatos, "Tab_Proveedores")
DdlFabricante.DataSource = dsDatos.Tables("Tab_Proveedores")
DdlFabricante.DataTextField = "Nombre_Proveedor"
DdlFabricante.Visible = True
DdlFabricante.DataBind()
DdlFabricante.Items.Insert(0, "SELECCIONE")
DdlFabricante.SelectedIndex = 0

y me da el nombre de los fabricantes, como puedo hacer para que al momento de seleccionar un item (nombre del fabricante), me muestre los demas datos que componen la tabla de proveedor en varios textbox por ejemplo seleccionar nombre del fabricante que es el Dropdownlist ejem Cannon y mostrar en varios textbox me muestre su correo electronico, Fax,Telefono. etc

Espero y me ayuden gracias
  #2 (permalink)  
Antiguo 07/01/2008, 21:32
Avatar de Peterpay
Colaborador
 
Fecha de Ingreso: septiembre-2007
Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 16 años, 8 meses
Puntos: 87
Re: Por Favor Ayuda urgente con un Dropdownlist !!!

Aqui hay un pequeño Ejemplo que puedes adaptar a tu necesidad

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=Deepra;uid=sa;pwd=;");
public static SqlDataAdapter ad;
SqlCommandBuilder cbuilder;
public static DataSet ds = new DataSet();
static int currentRow=0;
static string opMode="";
protected void ShowData()
{
TextBox1.Text = Convert.ToString(ds.Tables[0].Rows[currentRow].ItemArray[0]);
TextBox2.Text = Convert.ToString(ds.Tables[0].Rows[currentRow].ItemArray[1]);
TextBox3.Text = Convert.ToString(ds.Tables[0].Rows[currentRow].ItemArray[2]);
}
protected void LoadData()
{
ad = new SqlDataAdapter("select * from student", con);
cbuilder = new SqlCommandBuilder(ad);
ad.InsertCommand = cbuilder.GetInsertCommand();
ad.UpdateCommand = cbuilder.GetUpdateCommand();
ad.DeleteCommand = cbuilder.GetDeleteCommand();

ds.Clear();
ad.Fill(ds, "stud");
GridView1.DataSource = ds.Tables["stud"];
GridView1.DataBind();

ShowData();

TextBox1.ReadOnly = true;
TextBox2.ReadOnly = true;
TextBox3.ReadOnly = true;

BtnAdd.Enabled = true;
BtnEdit.Enabled = true;
BTnSave.Enabled = false;
}
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
LoadData();

//TextBox1.Text = (string)DataBinder.Eval(ds,"ds.Tables[0].DefaultView[0].Row[0]");
//TextBox2.Text = (string)DataBinder.Eval(ds.Tables["stud"], "Name");
//TextBox3.Text = (string)DataBinder.Eval(ds.Tables["stud"], "Address");
//Page.DataBind();
}
protected void BtnFirst_Click(object sender, EventArgs e)
{
currentRow = 0;
ShowData();
}
protected void BtnPrevious_Click(object sender, EventArgs e)
{
if (currentRow>0)
{
currentRow--;
ShowData();
}
}
protected void BtnNext_Click(object sender, EventArgs e)
{
if (currentRow < ds.Tables[0].Rows.Count-1)
{
currentRow++;
ShowData();
}
}
protected void BtnLast_Click(object sender, EventArgs e)
{
currentRow = ds.Tables[0].Rows.Count - 1;
ShowData();
}
protected void BtnFind_Click(object sender, EventArgs e)
{
DataRow[] dr=ds.Tables[0].Select("roll=" + Int32.Parse(TxtFind.Text));
if (dr.Length == 0)
{
Response.Write("Record Not Found");
}
else
{
TextBox1.Text = Convert.ToString(dr[0].ItemArray[0]);
TextBox2.Text = Convert.ToString(dr[0].ItemArray[1]);
TextBox3.Text = Convert.ToString(dr[0].ItemArray[2]);
currentRow = ds.Tables[0].Rows.IndexOf(dr[0]);
}
}
protected void BtnAdd_Click(object sender, EventArgs e)
{
opMode = "New";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";


TextBox1.ReadOnly = false;
TextBox2.ReadOnly = false;
TextBox3.ReadOnly = false;

BtnAdd.Enabled = false;
BtnEdit.Enabled = false;
BTnSave.Enabled = true;
}
protected void BtnEdit_Click(object sender, EventArgs e)
{
opMode = "Edit";

TextBox1.ReadOnly = true;
TextBox2.ReadOnly = false;
TextBox3.ReadOnly = false;

BtnAdd.Enabled = false;
BtnEdit.Enabled = false;
BTnSave.Enabled = true;
}
protected void BTnSave_Click(object sender, EventArgs e)
{
if (opMode == "New")
{

DataRow dr = ds.Tables[0].NewRow();
dr["roll"] = TextBox1.Text;
dr["Name"] = TextBox2.Text;
dr["Address"] = TextBox3.Text;
ds.Tables[0].Rows.Add(dr);
ad.Update(ds.Tables["stud"]);
Response.Write("Record saved");
currentRow = 0;
LoadData();
}
else if(opMode=="Edit")
{
ds.Tables[0].Rows[currentRow].BeginEdit();
ds.Tables[0].Rows[currentRow]["roll"]=this.TextBox1.Text;
ds.Tables[0].Rows[currentRow]["Name"]=this.TextBox2.Text;
ds.Tables[0].Rows[currentRow]["Address"] = this.TextBox3.Text;
ds.Tables[0].Rows[currentRow].EndEdit();
ad.Update(ds.Tables["stud"]);
Response.Write("Record saved");
currentRow = 0;
LoadData();
}

}
protected void BtnDELETE_Click(object sender, EventArgs e)
{
ds.Tables[0].Rows[currentRow].Delete();
ad.Update(ds.Tables[0]);
Response.Write("REcord DEleted");
currentRow = 0;
LoadData();
}
}


Puedes DEscomentar lineas y Ahorrar Codigo asociandolo al evento de cambio de seleccion de tu DDL
  #3 (permalink)  
Antiguo 07/01/2008, 21:34
Avatar de Peterpay
Colaborador
 
Fecha de Ingreso: septiembre-2007
Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 16 años, 8 meses
Puntos: 87
Re: Por Favor Ayuda urgente con un Dropdownlist !!!

//TextBox1.Text = (string)DataBinder.Eval(ds,"ds.Tables[0].DefaultView[0].Row[0]");
//TextBox2.Text = (string)DataBinder.Eval(ds.Tables["stud"], "Name");
//TextBox3.Text = (string)DataBinder.Eval(ds.Tables["stud"], "Address");
//Page.DataBind();


podria ser la solucion practica para tu duda
  #4 (permalink)  
Antiguo 08/01/2008, 09:46
 
Fecha de Ingreso: enero-2008
Mensajes: 4
Antigüedad: 16 años, 3 meses
Puntos: 0
Re: Por Favor Ayuda urgente con un Dropdownlist !!!

Muchas gracias Peterpay, pero si no fuera mucha molestia no tienes un ejemplo en visual basic.net es en el que estor trabajando.
  #5 (permalink)  
Antiguo 08/01/2008, 09:54
Avatar de Peterpay
Colaborador
 
Fecha de Ingreso: septiembre-2007
Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 16 años, 8 meses
Puntos: 87
Re: Por Favor Ayuda urgente con un Dropdownlist !!!

En VB.net no pero puedes buscar la equivalencia en el MSDN.

Sorry,

Saludos
Peterpay
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:29.