DynamicColumns\AccessingRows\DataGrid

G

gh

I create the columns for the asp.net datagrid at runtime and populates
them. I have a template column for checkboxs I created at runtime as
well. The user selects the product they want by checking the checkbox,
next to it. In the submit button I loop through the datagrids items and
if checked I will save the product to the cart. The problem is the grid
has no item count when I try to loop through it.

I loop through the rows of the grid right after I populate and add the
rows, in code, to make the checkboxs visible for certain rows and it
works great. Does it have something to do with the postback after
clicking the submit button?

Thanks
 
E

Eliyahu Goldin

Do you create the datagrid itself in runtime too? If you do, you have to
re-create it on every postback.

Eliyahu
 
G

gh

Eliyahu:

No, the data grid is not created at runtime. I have it on the form. I
create the columns and I fill them in a for loop. I dynamically create
the columns for the datagrid and add them to it. I then create a
datatable, add the columns to the datatable. I then create rows and
populate the columns of the rows and add them to the datatable. Then I
create a data using the datatable, for the datagrid. I call the
procedures, to create and fill the columns\rows, when the page is
loaded, inside if (!IsPostBack). I tried to save the
datagrid.datasource to a session var, then reassign it to the datagrid,
but there are no rows in it. I am not sure what event to put this in,
in order save it before the postback. What else could I be missing?

Thanks
 
E

Eliyahu Goldin

Is ViewState enable?

Eliyahu

gh said:
Eliyahu:

No, the data grid is not created at runtime. I have it on the form. I
create the columns and I fill them in a for loop. I dynamically create
the columns for the datagrid and add them to it. I then create a
datatable, add the columns to the datatable. I then create rows and
populate the columns of the rows and add them to the datatable. Then I
create a data using the datatable, for the datagrid. I call the
procedures, to create and fill the columns\rows, when the page is loaded,
inside if (!IsPostBack). I tried to save the datagrid.datasource to a
session var, then reassign it to the datagrid, but there are no rows in
it. I am not sure what event to put this in, in order save it before the
postback. What else could I be missing?

Thanks
 
G

gh

Yes it is, I just checked that. Is there away I can check the viewstate
in the page load event after I click the submit button?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top