Hello,
you can try this also
aspx markup:
<asp:CheckBoxList ID="CheckBoxList1" runat="server">
<asp:ListItem Value="book">The Book</asp:ListItem>
<asp:ListItem Value="pen">The Pen</asp:ListItem>
<asp:ListItem Value="color">The Color</asp:ListItem>
</asp:CheckBoxList>
Code behind:
public partial class CheckBoxLists : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int totalValue = 0;
foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
Choices currentChoice = (Choices)Enum.Parse(typeof(Choices),item.Value.ToString());
totalValue += (int)currentChoice;
}
}
Response.Write("Total Choices: " + totalValue.ToString());
}
}
public enum Choices
{
book = 100,
pen = 40,
color = 60
}
Enjoy....
Thanks,
Hemnat