Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
C#
protected void BtnSubmit_Click1(object sender, EventArgs e)
    {

        foreach (DataListItem item in DataList1.Items)
        {
            CheckBox lblNewsLetter = (CheckBox)item.FindControl("CheckBox1");
            Boolean bol1;
            bol1 = Convert.ToBoolean(lblNewsLetter.Checked);

            if (lblNewsLetter != null)
            {
                if (lblNewsLetter.Checked)
                {
                    Label1.Text += lblNewsLetter.Text + ",";
                }
                else
                {
                    Label1.Text = "Failed";
                }
            }
        }
    }

this is which i wrote the code, but this is not working fine.
suggest anyone plzzz..
here this is code showing checkbox.checked is false every time
plz correct it and tell me
thanks in advance
Posted
Comments
m@dhu 12-Aug-11 2:23am    
Use Add comment to reply don't post it as another solution. :)
sriranganadhk 12-Aug-11 3:10am    
here i want to insert checkbox.checked value into db.
every time it gives false result..
Manfred Rudolf Bihy 12-Aug-11 10:48am    
No text speak please! Read the FAQ

1 solution

Hiii.........

Did u give same name check box as finding control.........gve postback true..........


CheckBox lblNewsLetter = (CheckBox)item.FindControl("CheckBox1");
 
Share this answer
 
v2
Comments
m@dhu 12-Aug-11 2:21am    
comment from OP:
I edited my code as u said but it is not working. Is there any modifications i need to do?
please help me..
m@dhu 12-Aug-11 2:22am    
comment from OP(moved from answer):
here checkbox.checked is "false" it showing???
what to do??
Ashika s 12-Aug-11 2:26am    
y u checking not null condition? think logic wat u want displying or ur correct contest of?
Manfred Rudolf Bihy 12-Aug-11 10:47am    
No text speak here. Try checking your keyboard it seems to be broken.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900