protected void Button3_Click(object sender, EventArgs e) { try { SqlDataSource8.SelectParameters["Codigo"].DefaultValue = TextBox6.Text; SqlDataSource8.DataSourceMode = SqlDataSourceMode.DataReader; SqlDataReader Producto; Producto = (SqlDataReader)SqlDataSource8.Select(DataSourceSelectArguments.Empty); if (Producto.Read()) { TextBox7.Text = Producto["Descripcion"].ToString(); Label1.Text = Producto["ID_Producto"].ToString(); } else { Response.Write("<script>alert('Este producto no existe')</script>"); } } catch { Response.Write("<script>alert('Ingrese un codigo!')</script>"); } //DataTable TB = new DataTable(); //TB = datosProd.BuscarProducto2(TextBox6.Text); //try //{ // ViewState["Estado"] = TB; // if (ViewState["Estado"] == null) // { // Response.Write("<script>alert('Este producto no existe')</script>"); // } // else // { // TextBox7.Text = TB.Rows[0][1].ToString(); // } //} //catch //{ // Response.Write("<script>alert('Este producto no existe')</script>"); //} }
protected void Button3_Click(object sender, EventArgs e) { try { SqlDataSource8.SelectParameters["Codigo"].DefaultValue = TextBox6.Text; SqlDataSource8.DataSourceMode = SqlDataSourceMode.DataReader; SqlDataReader Producto; Producto = (SqlDataReader)SqlDataSource8.Select(DataSourceSelectArguments.Empty); if (Producto.Read()) { TextBox7.Text = Producto["Descripcion"].ToString(); Label1.Text = Producto["ID_Producto"].ToString(); } else { Response.Write("<script>alert('Este producto no existe')</script>"); } } catch { Response.Write("<script>alert('Ingrese un codigo!')</script>"); } }