ASP:RadioButtonList 数据绑定自定义对象
嘿伙计们,我的 ASP:RadioButtonList 遇到了一些麻烦,搜索了 Google 等等,没有运气,你能帮我吗?
我在数据绑定方面遇到问题。 我有一个如下所示的自定义类:
public class myClass{
public myInnerClass{
public int myID;
public String myTextField;
/* other fields*/
}
public List<myInnerClass> myList;
}
我正在尝试将其内部类的通用列表绑定到无线电列表:
protected void Page_Load(object sender, EventArgs e){
myClass data = anotherClass.getData();
uxRadioList1.DataSource = data.myList;
uxRadioList1.DataTextField = "myTextField";
uxRadioList1.DataValueField = "myID";
uxRadioList1.DataBind();
}
但它就是不会去。 当我没有指定它绑定的 DataTextField 和 DataValueField 字段时,但它显示 'myClass+myInnerClass' 。 我该如何正确地做到这一点?
Hey guys, I'm having a bit of trouble with my ASP:RadioButtonList, searched Google and SO, no luck, can you help me out?
I'm having trouble databinding. I've got a custom class that looks like this:
public class myClass{
public myInnerClass{
public int myID;
public String myTextField;
/* other fields*/
}
public List<myInnerClass> myList;
}
And I'm trying to bind a Generic List of it's inner class to a radiolist:
protected void Page_Load(object sender, EventArgs e){
myClass data = anotherClass.getData();
uxRadioList1.DataSource = data.myList;
uxRadioList1.DataTextField = "myTextField";
uxRadioList1.DataValueField = "myID";
uxRadioList1.DataBind();
}
But it just won't go. When I don't specify the DataTextField and DataValueField field it binds, but it displays 'myClass+myInnerClass' . How do I do this properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你只能绑定到公共属性,而不能绑定到字段。 尝试将 myInnerClass 的字段更改为属性:
I think you can only bind to public properties, but not to fields. Try changing the fields of myInnerClass to properties: