Ejemplo de storeprocedure y gridview 1.crear un storeprocedure con las tablas: Employees(employeeID,lastname,firstname,city) EmployeesTerritories Territories(territoryDescription) Agregar en el where: where Employees.EmployeeID=@empleadoID 2. Crear formulario Poner gridview(,caja de texto(txtEmp) y boton(button1) 3.agregar una fuentededatos datasource para usar la cadena de conexión 4. escribir código. using using using using using using using using System; System.Collections.Generic; System.Linq; System.Web; System.Web.UI; System.Web.UI.WebControls; System.Data; System.Data.SqlClient; namespace WebApplicatiobd111.ejemplo { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } //agregar codigo public DataSet CargaGrid(int iId) { string sCon = "Data Source=.;Initial Catalog=Northwind;Integrated Security=True"; SqlConnection oCOn = new SqlConnection(sCon); SqlDataAdapter da = new SqlDataAdapter("muestra_empleado_region1", sCon); da.SelectCommand.CommandTimeout = 0; da.SelectCommand.CommandType = CommandType.StoredProcedure; da.SelectCommand.Parameters.Add("@empleadoID", SqlDbType.Int).Value = iId; DataSet ds = new DataSet(); try { da.Fill(ds); da.Dispose(); return ds; } catch (Exception ex) { throw ex; } } protected void Button1_Click(object sender, EventArgs e) { 1 try { int iIdEmp = Convert.ToInt32(txtEmp.Text == string.Empty ? "0" : txtEmp.Text); DataSet ds = CargaGrid(iIdEmp); grvEmpleados.DataSource = ds; grvEmpleados.DataBind(); } catch (Exception ex) { string sScript = @" "; Page.ClientScript.RegisterStartupScript(Page.GetType(), "Error Grid", sScript); } } } } 5..poner un script manager. 6. ejecutarlo 2