This is a migrated thread and some comments may be shown as answers.

How to remove the columns in the viewstate.

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
digish devassy
Top achievements
Rank 1
digish devassy asked on 13 Mar 2012, 03:18 PM

Hi,

I am binding the radgrid using normal datasource and databind method.

the grid is getting filled with autogenerated columns. I have placed one checkbox which is in the grid, not auto generated.

Now, on post back usong any button in the page. the data in the viewstate also gets loaded. this creates addtional column. I did
radgrid.MasterTableView.Columns.Clear();

the reaction is, this will also remove the checkbox in the item template. I am not sure on how to add check box and header text box in the item template in radgrid programmatically. the example given in telerik site is not helpful.

http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html

I requrie a solution, on how to added a column which checkbox programmatically or

 

running this without touching template column or
prevent viewstate from acting on button postbacks.

thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 19 Mar 2012, 09:37 AM
Hello,

The behavior you are observing could be caused if you are creating the structure of RadGrid on button click and thus every time you press the button new set of columns will be added to RadGrid.

Another approach is if you are creating the structure of RadGrid on Page_Load event and you are not checking whether the page has been postbacked to the server.

You could try to wrap this if statement around the code that you are using to generate the RadGrid structure:

if (!Page.IsPostBack)
{
    // your code goes here....
}

Could you post your RadGrid declaration along with the respective event handlers. Thus all the people who want to help you will  have better understanding of your project.

All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
digish devassy
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or