I am trying to get selected value from my checkbox (talking about only single result/check), I want to get that value on event onClick on my button, and not only checkbox I also got there two dropdown lists that I am taking also selected value out of, and when I click my button, I get values from dropdown lists and I can't get value from checkboxlist and I dont know why because I set allready before on page load source and eveything seems to look fine but I can't get value :/

Here is the code:

 protected void btnSearch_Click(object sender, EventArgs e)
       var dropDown_one= Convert.ToInt32(dropOne.SelectedValue); //THIS IS OK
       var dropDown_two = Convert.ToInt32(dropTwo.SelectedValue);//THIS IS OK
       var checkBox = Convert.ToInt32(checkBox.SelectedValue); //<- here I got error, because I am trying to convert "" value to int


and on page load I dId this:

checkBox.DataSource =SomethingFromDatabase();
        checkBox.DataTextField = "Name";
        checkBox.DataValueField = "ID";

So I got values from Database and I am able to check them, but when I click my button I got error because checkboxlist says that its value is "" so like I did not select anything even if I did.. :/

Thanks guys, Cheers

Related posts

Recent Viewed