私はこのカスタムラジオボタンリストを持っています。同じ.aspxページで2つのRadiobuttonListコントロールを持つため、実際にGroupNameを取得できるようにするには私の.aspxページで使用しています。RadioButtonList SelectedItemは常にEmptyStringを返します
public class CustRadioButtonList : RadioButtonList, IRepeatInfoUser
{
void IRepeatInfoUser.RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
{
RadioButton radioButton = new RadioButton();
radioButton.Page = this.Page;
radioButton.GroupName = "radioButtonGroup";
radioButton.ID = this.ClientID + "_" + repeatIndex.ToString();
radioButton.Text = this.Items[repeatIndex].Text;
radioButton.Attributes["value"] = this.Items[repeatIndex].Value;
radioButton.Checked = this.Items[repeatIndex].Selected;
radioButton.TextAlign = this.TextAlign;
radioButton.AutoPostBack = this.AutoPostBack;
radioButton.TabIndex = this.TabIndex;
radioButton.Enabled = this.Enabled;
radioButton.RenderControl(writer);
}
}
これは単なるエクステンションです.GroupNameを設定すると、そのRadioButtonListで作成されたすべてのラジオボタンが同じGroupNameを持つようになります。そうすれば、誰かがRadiobuttonList1から値を選択すると、 Radiobutton2ではその逆もあります(したがって、これらは相互排他的なラジオボタンのセットです)。
注:ラジオボタンリストは、確実に!Page.IsPostBackのチェックにラップされたメソッド呼び出しによってバインドされているので、ここで問題はありません。ここで
は、私は私の.aspxページでそれを使用している例です。
<aj:CustRadioButtonList checked="false" ID="rblEmail" runat="server" />
<aj:CustRadioButtonList checked="false" ID="rblReason" runat="server" />
ここに私のコードビハインドで、私ものonclickの内rblEmailからSelectedValueのためにチェックしています私は入れませんなぜ今把握しようと周りに一日を費やしてきた
protected void btnContinue_Click(object sender, EventArgs e)
{
_actionID = rblEmail.SelectedValue;
:私のpage..but上のボタンは、それは常に私がリスト内の項目を選択している場合でも、空の文字列を返しはっきりと私はVAを選択したときにemptystring rblEmailのlue。他のラジオボタンリストrblReasonでも同じです。どちらの場合でも、コードビハインドからチェックするとき、私はSelectedValueに対してemptystringを取得します。
あなたはマークアップを見れば、ここではそれがどのように見えるかです:
<table id="rblEmail" checked="false" border="0">
<tr>
<td><input id="rblEmail_0" type="radio" name="radioButtonGroup" value="0" /><label for="rblEmai_0">All Offers</label></td>
</tr><tr>
<td><input id="rblEmail_1" type="radio" name="radioButtonGroup" value="1" /><label for="rblEmail_1">week</label></td>
</tr><tr>
<td><input id="rblEmail_2" type="radio" name="radioButtonGroup" value="2" /><label for="rblEmail_2">month</label></td>
</tr><tr>
<td><input id="rblEmail_3" type="radio" name="radioButtonGroup" value="3" /><label for="rblEmail_3">Holiday</label></td>
</tr>
</table>
</div>
...
<table id="rblReason" checked="false" border="0">
<tr>
<td><input id="rblReason_0" type="radio" name="radioButtonGroup" value="1" /><label for="rblReason_0">I receive</label></td>
</tr><tr>
<td><input id="rblReason_1" type="radio" name="radioButtonGroup" value="2" /><label for="rblReason_1">I have no need</label></td>
</tr><tr>
<td><input id="rblReason_2" type="radio" name="radioButtonGroup" value="3" /><label for="rblReason_2">Other</label></td>
</tr>
</table>
ただ、なぜこれが動作しないため、単一の通常のRBLを使ってしまう、不思議? –
どのように私はそれを吐き出すだろう、私は両方のコントロールに5 radiobuttonsがあります。リピータ内にasp.net radiobuttonの単一のコントロールを置くことは、Groupingの問題とほぼ同じです。GroupNameに関連するバグは、コントロールのUniqueIDでオーバーライドされます。 私は不思議です。 – user72603
Rex、あなたが何を意味するかを詳しく説明してください。あなたはリピーターと話していますか?私はそれを見て、グルーピングの問題とほぼ同じような問題を見つけました。なぜ同じ問題で私の時間を無駄にするのかについての例は – user72603