Saturday, June 28, 2008

The RIGHT way to use checkboxes in a .NET Repeater!

The Code-Behind


Here retrieve checkbox value in case of repeater


public void DoSend(object sender, EventArgs e)
{.

foreach (RepeaterItem i in customerList.Items)
{.

//Retrieve the state of the CheckBox.

CheckBox cb = (CheckBox)i.FindControl("selectUser");.

if (cb.Checked)
{.

//Retrieve the value associated with that CheckBox.

HiddenField hiddenEmail = (HiddenField)i.FindControl("hiddenEmail");.


//Now we can use that value to do whatever we want.

SendWelcomeMessage(hiddenEmail.Value);.

}
}.

}.





No comments: