バインドされたHtml5データ属性をバインドされたアイテムに追加するにはどうすればよいRadioButtonList
ですか?
私のコードは次のようになります:
<asp:Repeater Id="QuestionList" ...>
<ItemTemplate>
<asp:RadioButtonList DataSource='<%# Eval("Answers") %>'
SelectedValue='<%# Eval("SelectedAnswerId") %>'
DataTextField="Answer"
DataValueField="AnswerId"
Tag='<%# Eval("QuestionId") %>' />
</ItemTemplate>
</asp:Repeater>
var List<Question> questions = GetQuestions();
QuestionList.DataSource = questions;
QuestionList.DataBind();
これは、次のようなクラス構造にバインドされています。
public class Question
{
int QuestionId;
string Question;
List<Answer> Answers;
}
public class Answers
{
int AnswerId;
string Answer;
bool SomeFlag;
}
jQueryを使用するためにUIに追加SomeFlag
する必要があるため、最終的に生成される各アイテムは次のようになります。
<input type="radio" data-flag="true" ... />
バインドから生成された入力オブジェクトにhtmldata-属性を追加する方法はありますRadioButtonList
か?