By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,492 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,492 IT Pros & Developers. It's quick & easy.

DynamicColumns\AccessingRows\DataGrid

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.