C sharp - consulta

 
Vista:

consulta

Publicado por orlando (1 intervención) el 16/09/2008 22:47:06
hola amos alguien me podria decir como puedo buscar en un datagriview osea me explico mejor....

en un textbox escribo y se filtar en el data cumo hago eso?
cualquier ayuda sera agradecida
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:consulta

Publicado por Alfredo Barrios (9 intervenciones) el 10/10/2008 01:19:15
Mira, te lo voy a plantear de otra forma, el data grid lo llenas con un data source que generalmente es un datatable, ¿de acuerdo?, entonces hagamos lo siguiente:

private DataTable DataTableMiniGrid1(DataRow[] rows)
{
DataTable drTabla = new DataTable();
foreach (DataColumn col in tblMiniGrid1.Columns) {
DataColumn myColumn;
myColumn = new DataColumn();
myColumn.DataType = col.DataType;
myColumn.ColumnName = col.ColumnName;
drTabla.Columns.Add(myColumn);
}
foreach (DataRow row in rows)
{
drTabla.ImportRow(row);
}
return drTabla;
}
private void filltblMiniGrid1(){
rrModulosFuncionesDAO orrModulosFunciones = oDAOFactoryImpl.create_rrModulosFuncionesDAO();
orrModulosFunciones.ConnectionString = ConfigurationManager.ConnectionStrings["SecureSAVEConn"].ToString();
tblMiniGrid1 = orrModulosFunciones.Select(Id_Funcion, 4);
}
private void Fill_dgMiniGrid1()
{
if (tblMiniGrid1 == null)
{
filltblMiniGrid1();
}
try
{
dgMiniGrid1.DataSource = DataTableMiniGrid1(tblMiniGrid1.Select("IsDeleted='N'")).DefaultView;
dgMiniGrid1.VirtualItemCount = 0;
dgMiniGrid1.AllowSorting = false;
dgMiniGrid1.DataBind();
if (tblMiniGrid1.Rows.Count == 0)
{
dgMiniGrid1.Columns[2].Visible = false;
}
else
{
dgMiniGrid1.Columns[2].Visible = true;
}
}
catch (Exception oExcep)
{
lblError.CssClass = "errorStyle";
lblError.Text = "Hubo un error al intentar llenar el Grid";
}
}
protected void btnAgregarModulo_Click(object sender, EventArgs e)
{
/********************************************************************
btnAgregarLicencia_Click method
Description:
*********************************************************************

Generate by Application Generator - ABC Systemes
Date: 05-07-2008
*********************************************************************
Modifications
Date Who Comments
********************************************************************/
try
{
DataRow[] rows = tblMiniGrid1.Select("Id_Modulo=" + cbxId_Modulo.SelectedValue);
if (rows.Length == 0)
{
DataRow drRenglon = tblMiniGrid1.NewRow();
drRenglon["Id_Modulo"] = Convert.ToInt16(cbxId_Modulo.SelectedValue);
drRenglon["Descripcion"] = cbxId_Modulo.SelectedItem.Text;
drRenglon["IsDeleted"] = "N";
tblMiniGrid1.Rows.Add(drRenglon);
Fill_dgMiniGrid1();
}
else {
lblError.CssClass = "errorStyle";
lblError.Text = "Ya existe este modulo";
}
}
catch (Exception oExcep)
{
lblError.CssClass = "errorStyle";
lblError.Text = "Hubo un error al intentar llenar el Grid";
}
}
protected void dgMiniGrid1_DeleteCommand(object source, DataGridCommandEventArgs e)
{
/********************************************************************
dgPhoneList_DeleteCommand
Description:
*********************************************************************

Generate by Application Generator - ABC Systemes
Date: 05-07-2008
*********************************************************************
Modifications
Date Who Comments
********************************************************************/
try
{
DataRow[] row = tblMiniGrid1.Select("Id_Modulo=" + e.Item.Cells[0].Text);
row[0]["IsDeleted"] = "S";
Fill_dgMiniGrid1();
}
catch (Exception oExcep)
{
lblError.CssClass = "errorStyle";
lblError.Text = "Hubo un error al intentar llenar el Grid";
}
}
Espero que con esto me haya explicado, sino, escribeme.

Saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar