Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
235
About grid functionalities
posted

Good Morning.

I have an error when I try delete a row in WebDataGrid control.

I have a DataSet like DataSource and this DataSet is storage in Session.

I insert and update without problems, but when I try to delete I take the value of the "NumeroFila" column

of the row to delete and erases this row from the DataSet, later Update the "NumeroFila" with a consecutive number and

I bind the new DataSet to the WebDataGrid control,but, I receive this javascript error:

0x800a139e - Error en tiempo de ejecución de BLOCKED SCRIPT Sys.WebForms.PageRequestManagerServerErrorException: Index was out of range. Must be non-negative and less than the size of the collection.

 

What do I can do?, What happened with the WebDataGrid control because it does not change the DataSource correctly?

WebSite2.zip
  • 25665
    Offline posted

    Hello Edward,

    Thank you for contacting Infragistics!

    I have taken a look at your code and have been able to find what is causing this. The cause is how you have your CargarGrid method setup and the fact that you haven’t set AutoCURD to false on the editing core behavior.

    The reason for AutoCRUD being set to false is you are assigning a dataset/datatable to your grid and when you do this you have to do your updates manually.

    With you reassign the datasource every change it things it is a new datasoure. Instead you should do the following.

    private void CargarGrid()
        {
            DataSet dsPatronEmpaque = null;

            if (Session["PatronEmpaque"] == null)
            {
                dsPatronEmpaque = CrearEstructuraDataSet();
                Session["PatronEmpaque"] = dsPatronEmpaque;
            }

            wdgEspecificacionxFila.DataSource = Session["PatronEmpaque"];
           
        }

    Note I also recommend you set EnableDataViewState to false and in page load do the following:

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InicializarWebDataGrid();
                CargarGrid();
            }
            else
            {
                wdgEspecificacionxFila.DataSource = Session["PatronEmpaque"];
            }
        }

    The reason for this is when EnableDataViewState is set to true and you do updates/adds/deletes it can sometimes cause issues with the old value being maintained instead of the new ones. I am attaching your modified sample.

    WebSite2.zip