-
RadiobuttonGroup
Hi all !
I cannot clear a radiobuttongroup.checkeditems:
After the line radButtons.CheckedItems.Clear(); CheckedItems.Count is still > 0
I have to set unchecked all buttons manually:
radButton0.Checked = false;
radButton1.Checked = false;
radButton2.Checked = false;
Another related question: How can I easily check the right button in a group? Is there any automatic way? I know buttongroup has a Value property but I'm not sure it's what I want, I wish I could set buttongroup value and then the right button get checked and the rest cleared in that group.
Here is my code:
Code:
radGeziDurumu.CheckedItems.Clear();
try
{
switch (Convert.ToInt16(query.Result.Rows[0]["geziDurumu"]))
{
case 0: radGeziDurumu0.Checked = true; break;
case 1: radGeziDurumu1.Checked = true; break;
case 2: radGeziDurumu2.Checked = true; break;
}
}
catch { radGeziDurumu0.Checked = true; }
P.S: code wrapping is buggy?
-
RE: RadiobuttonGroup
Hi,
It is just collection of inner controls which checked (rebuild for each getter calling)
Try the following code to clear selection
Code:
RadioGroup1.CheckedItems.ForEach(checkbox => checkbox.Checked=false);
Or you can call
Code:
RadioGroup1.Reset();
It will clear selection on client side (but for current request the CheckedItems will still show checked items because Reset operation should be executed on client side and after that in next request you will see result)
-
RE: RadiobuttonGroup
Any advise to check the right radiobutton in a group? I found a Flex example that's what I said before; it has a selectedValue property. That property automatically clears the buttons & check one of them which matches.
Code:
<p style="font-size: 1.083em; line-height: 1.462; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: 0px; margin-left: 0px; "><mx:FormItem label="OnSale"></p><p style="font-size: 1.083em; line-height: 1.462; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: 0px; margin-left: 0px; "><mx:<b style="color: black; background-color: rgb(160, 255, 255); ">RadioButtonGroup[/b] id="onSaleGroup" selectedValue="true" /></p><p style="font-size: 1.083em; line-height: 1.462; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: 0px; margin-left: 0px; "><mx:RadioButton groupName="{onSaleGroup}" label="TRUE" value="true" /></p><p style="font-size: 1.083em; line-height: 1.462; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: 0px; margin-left: 0px; "><mx:RadioButton groupName="{onSaleGroup}" label="FALSE" value="false" /></p><p style="font-size: 1.083em; line-height: 1.462; margin-top: 0px; padding-bottom: 0px; margin-bottom: 0px; padding-top: 0px; padding-right: 0px; padding-left: 0px; margin-right: 0px; margin-left: 0px; "></mx:FormItem></p>
I also tried
Code:
radGeziDurumu.Value = Convert.ToInt16(query.Result.Rows[0]["geziDurumu"]);
radGeziDurumu.Items.ForEach(checkbox => (radGeziDurumu.Value == checkbox.Value ? checkbox.Checked = true : checkbox.Checked = false);
but it's not allowed : ) I have to use real for-each loop : (
-
RE: RadiobuttonGroup
That's it:
Code:
radGeziDurumu.Items.ForEach(checkbox => checkbox.Checked = checkbox.ID == "radGeziDurumu" + radGeziDurumu.Value ? true : false);