我该如何为绑定的
我需要在UI中添加
有没有办法在绑定的RadioButtonList生成的输入对象中添加一个html data属性?
RadioButtonList
生成的项目添加一个绑定的Html5 data- attribute?以下是我的代码:<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;
}
我需要在UI中添加
SomeFlag
以供jQuery使用,因此生成的每个项目最终应该看起来像这样:<input type="radio" data-flag="true" ... />
有没有办法在绑定的RadioButtonList生成的输入对象中添加一个html data属性?