problem with Page post back and SaveTablesStructure function

5 replies. Last post: August 8, 2011 10:11 PM by Riendy Setiadi
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

Hi Dev team,

One of the core requirements of my project is to save the template (the choice of the columns to display with filter, sort, group options). I have a web grid and a save button on the web-page. I am doing the following to bind the web grid with the data coming from Oracle 11G :

protected void gridView_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)

        {

            if(_resultSet != null)

                e.DataSource = _resultSet.Tables[0];           

        }

where, _resultSet is a dataset with the data coming from the database.

protected void gridView_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)

        {

            if (IsPostBack && !gridView.IsFlyPostBack)

            {

if (_resultSet != null)

                    {

                       foreach (DataColumn dcol in _resultSet.Tables[0].Columns)

                        {

                            WebGridColumn col = new WebGridColumn();

                            col.DataMember = dcol.ToString();

                            col.Caption = dcol.ToString();

                            

                            gridView.RootTable.Columns.Add(col);

                            //gridView.RootTable.DataMember


                        }

                    }

          gridView.RetrieveStructure();

}

Then, I am manipulating the column positions and adding some filters and grouping. Everything works fine till then. After that when I call the Button Save click event to save the changes in the webgrid, it doesnt write the changes in the webgrid, instead just writes the original state of the webgrid (before changes in the column positions and filtering, grouping).

protected void btnSave_Click(object sender, EventArgs e)

        {

            if (gridView.DataSource != null)

            {

gridView.SaveTablesStructureToXml(Server.MapPath("layout.xml"));

}

}

On top of it, after the postback that happens due to button click event, I lose the state of the grid and the grid shows the data without the filtering, grouping, change in the column position. 

Please suggest me how to save the table structure of the grid in the xml as well as maintaining the state of the grid after post back. Due to dynamic nature of the data coming from the database, I can not make Strongly typed datatable to bind the data to the grid.

Thanks

Udy

All times are GMT -5. The time now is 9:55 PM.
Previous Next