all groups > asp.net datagrid control > june 2006 >
You're in the

asp.net datagrid control

group:

How to get checkbox value from datagrid...



How to get checkbox value from datagrid... JLuv
6/27/2006 12:25:01 PM
asp.net datagrid control: right now i'm trying the method...

int i = 0;
foreach (DataGridItem dgItem in pGrid.Items) //(int i = 0; i <
pGrid.Items.Count; i++)
{
if (((CheckBox)dgItem.FindControl("check")).Checked)
{
i++;
}
}
Response.Write(i);

just to see if i'm getting the correct amount of checks. however, i've
gone into the debugger and saw that it has each checkbox as false even
when checked.
now if i can get that part to work correctly, how would i get the data
from the datagrid for each checked box?
any help?
Re: How to get checkbox value from datagrid... MJ
6/30/2006 10:13:02 AM
Hi
you try this.
with one Template column,
code
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox --> Cheched ='<%# DataBinder.Eval(container,
"dataitem.indicador")%>'
-----------
This field of database must is type Bit, with this best control when
extract record since database

Chress


"Bruno Alexandre" escribió:

[quoted text, click to view]
Re: How to get checkbox value from datagrid... JLuv
6/30/2006 10:26:47 AM
i found my answer. i ended up doing a foreach loop like this...

foreach (DataGridItem dgItem in theGrid.Items)
{
if (((CheckBox)dgItem.FindControl("select")).Checked)
{
myString = this.theGrid.Items[i].Cells[3].Text;
//do other stuff
}
i++;
}
Re: How to get checkbox value from datagrid... Bruno Alexandre
6/30/2006 3:24:48 PM
you can't do like that, as it sounds the correct way to do it...
you ned to run all rows in the gridView instead itens...

foreach (GridViewRow row in pGrid.Rows)
{

cb = ((CheckBox)row.FindControl("check")).Checked;

}

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)


"JLuv" <JLuv3k6@gmail.com> escreveu na mensagem
news:1151436301.601157.212010@j72g2000cwa.googlegroups.com...
[quoted text, click to view]

AddThis Social Bookmark Button