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

Checkbox in datalist with ASP.net

P: 23
i have checkbox in datalist and i need to find which checkbox is checked
name of checkbox = CheckBox1
and name of datalist is DataList1

i am writng this code to find the checked checkbox

foreach (DataListItem dli in DataList1.Items)
{

bool ok = ((CheckBox)dli.FindControl("CheckBox1")).Checked;
if (ok)
{
// ok
}
}


but the result is always false what i have to do


10x
Oct 16 '07 #1
Share this Question
Share on Google+
5 Replies


P: 23
please reply urgent


10x
Oct 19 '07 #2

kenobewan
Expert 2.5K+
P: 4,871
What event are you using? More info please.
Oct 19 '07 #3

P: 23
What event are you using? More info please.

in my web page i have a button to check all checked checkbox
so i use Button_Click Event

i think the problem is how can i refresh my page

please reply

10x for helping me
Oct 19 '07 #4

kenobewan
Expert 2.5K+
P: 4,871
Suggest you debug - is the event firing?
Oct 20 '07 #5

P: 3
Solution To checkbox checked=false in datalist

Bind the data when page.ispostback is false

if( ! page.ispostback)
{
bindyourdata();
}


Comment:The problem why checkbox is showing checked status false is when u press the button, page post back occurs and datalist is populated again. So bind the data when page.ispostback is false
Feb 29 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.