Pregunta

Tiene que haber una manera de permitir la creación e inserción de un registro de una AxGridView sin utilizar el túnel y el enfoque Asistente. Por lo que he encontrado en Internet hasta el momento, el único ejemplo es el uso de un asistente, y sinceramente, no parece que sea un enfoque fácil de usar.

¿Alguien ha tratado de permitir la inserción de los registros directamente desde un AxGridView?

¿Fue útil?

Solución

Si es posible introducir datos a través AxGridView. Solamente es necesario activar editar, borrar para ese control. Y una cosa más para hacer nueva fila - usted tiene que hacer botón addditional - crear nueva línea, y el código subyacente:

protected void NewLine_Click(object sender, EventArgs e)
{
    int editIdx = AxGridView1.EditIndex;      

    try
    {
        // Save the last unsaved line if any
        if (AxGridView1.EditIndex != -1 && AxGridView1.Rows.Count > 0)
        {
            this.AxGridView1.UpdateRow(AxGridView1.EditIndex, true); 
        }


        DataSetViewRow dsvr = this.dsv.AddNew();        
    }
    catch (System.Exception ex)
    {
        AxExceptionCategory exceptionCategory;

        if (!AxControlExceptionHandler.TryHandleException(this, ex, out exceptionCategory))
        {
            // Throw the fatal exception
            throw;
        }
        if (exceptionCategory == AxExceptionCategory.NonFatal)
        {
            AxGridView1.EditIndex = editIdx;
        }
    }
}

private DataSetView dsv //get dataset view
    {
        get
        {
            DataSet dataSet = this.AxDataSource1.GetDataSet();
            return dataSet.DataSetViews[this.AxGridView1.DataMember];
        }
    } 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top