Checkbox in a datagrid

G

Guest

I have a datagrid that has a column of checkbox in every row. And also 2
columns of 2 forms, each form with a textarea and a submit button. I have a
button below the datagrid. And I place a form that run at server before the
datagrid and after the button.

When I click the button, i want to find out which checkbox are checked. So,
I did it by looping through each datagriditem, and determine which checkbox
control have been selected. I followed according to what the websites i found
teach. Something like
Dim dgitem As DataGridItem
for each dgitem in dg.items
dim mycheckbox as checkbox = dgItem.FindControl("chkPrint")
if mycheckbox.checked = true then
....

i also tried Ctype command and etc. But it always return the value as false.
I think it's because the form is reload and that's why the value is also
false...

Any ideas? Thank you
 
G

Guest

Hi Wrytat,

In order to avoid datagrid reloading, you can use following code in
Page_Load event

if(!IsPostBack)
{
datagrid.DataSource = getDataSource();
datagrid.DataBind();
}


HTH

Elton Wang
(e-mail address removed)
 
G

Guest

Thank you~

Elton W said:
Hi Wrytat,

In order to avoid datagrid reloading, you can use following code in
Page_Load event

if(!IsPostBack)
{
datagrid.DataSource = getDataSource();
datagrid.DataBind();
}


HTH

Elton Wang
(e-mail address removed)
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top