Click here to Skip to main content
15,911,890 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all
I have a function that fills a group of data in the run time using datareader.
on of that data is generating checkbox that holds the id of its row from datareader too.
now i have a button if clicked takes the id of checkbox that is checked and delete by it.
I tried it but in the button click, see the checkbox id = null;

C#
Account += "<div class='topic_row'>";               
             chkList1 = new CheckBox();
               chkList1.ID = dr["mobile"].ToString();
               chkList1.Font.Name = "Verdana";
               chkList1.Font.Size = 80;
               chkList1.Height = 45;
               chkList1.TextAlign = TextAlign.Left;
               siiii.Controls.Add(chkList1);
               Account += "</div>";

void btn_delete_Click(object sender, EventArgs e)
{
 Delete_Account(Convert.ToInt64(cmb_MobileSubGroup.SelectedItem.Value.ToString()), chkList1.ID.ToString()); 

}



any help
thanks
Posted
Updated 9-Mar-11 0:32am
v3
Comments
Layinka 9-Mar-11 8:29am    
Can you say where the checkbox is coming from,this will help find the problem.
Also are you sure there's no duplicate ID being generated as a result of the data in the tables?
maulikmakadiya 9-Mar-11 23:21pm    
In ASP.Net, It must require to set checkbox Property named "posturl=True" so it set to true when checkbox is clicked.
Ig. chkList1.Posturl=True Something..
JV9999 11-Mar-11 3:04am    
That property you mentioned doesn't even exist and never existed either.

1 solution

There are a few things you can check. It's hard being precise when you didn't post the entire code.

I see that the Account variable is set with += are you generating several chList1? If so they are all named chkList1 and the server wount bind the event handler. The .ID = is just for the HTML code and doesn't bind any events.

Check to see that the checklist control get's the runat="server" attribute set.

Hopes this helps. Otherwise post your entire page code and I will see what I can do.
 
Share this answer
 
Comments
Dalek Dave 13-Mar-11 17:00pm    
Good Call.

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