【发布时间】:2015-10-18 02:26:37
【问题描述】:
我的 ASP.NET 项目中有一个分页 GridView,我在其中将人力资源插入数据库。每次将所有人力资源插入数据库时,我的 GridView 都会加载。 现在,每次我添加新行(人力资源)或修改现有行时,我希望它在网格中突出显示,以使用户清楚地知道操作已执行。我还没有找到一个好方法,而且gridview被分页的事实使它更加复杂。我会很感激一些帮助:)
我通过将网格与数据表绑定来添加行:
protected void llenarGrid() //se encarga de llenar el grid cada carga de pantalla
{
DataTable recursosHumanos = crearTablaRH();
DataTable dt = controladoraRecursosHumanos.consultarRecursoHumano(1, 0); // en consultas tipo 1, no se necesita la cédula
Object[] datos = new Object[4];
if (dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
datos[0] = dr[0];
datos[1] = dr[1];
datos[2] = dr[2];
int id = Convert.ToInt32(dr[3]);
String nomp = controladoraRecursosHumanos.solicitarNombreProyecto(id);
datos[3] = nomp;
recursosHumanos.Rows.Add(datos);
}
}
else
{
datos[0] = "-";
datos[1] = "-";
datos[2] = "-";
datos[3] = "-";
recursosHumanos.Rows.Add(datos);
}
RH.DataSource = recursosHumanos;
RH.DataBind();
}
protected DataTable crearTablaRH()
{
DataTable dt = new DataTable();
dt.Columns.Add("Cedula", typeof(int));
dt.Columns.Add("Nombre Completo", typeof(String));
dt.Columns.Add("Rol", typeof(String));
dt.Columns.Add("Nombre Proyecto");
//dt.
return dt;
}
【问题讨论】:
-
您应该发布相关代码和标记。如果你不这样做,很难说出你是如何插入你的行的,这意味着无论谁回答都必须花更少的时间来处理它(所以你更有可能得到答案)和答案将更适合您的情况。
-
您好,感谢您的评论,我会尽快编辑问题。