Checkbox in a datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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)
 
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)
 
Back
Top