473,385 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DynamicColumns\AccessingRows\DataGrid

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

Feb 26 '06 #1
4 1555
Do you create the datagrid itself in runtime too? If you do, you have to
re-create it on every postback.

Eliyahu

"gh" <gh@attt.net> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl...
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

Feb 26 '06 #2
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

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

Eliyahu

"gh" <gh@attt.net> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl...
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



Feb 26 '06 #3
Is ViewState enable?

Eliyahu

"gh" <gh@attt.net> wrote in message
news:u9****************@tk2msftngp13.phx.gbl...
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

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

Eliyahu

"gh" <gh@attt.net> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl...
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


Feb 26 '06 #4
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

Eliyahu Goldin wrote:
Is ViewState enable?

Eliyahu

"gh" <gh@attt.net> wrote in message
news:u9****************@tk2msftngp13.phx.gbl...
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

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

Eliyahu

"gh" <gh@attt.net> wrote in message
news:OH**************@TK2MSFTNGP12.phx.gbl...
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



Feb 26 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.