- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
aspx 文件:
<asp:Repeater ID="Repeater_sorular" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<div class="div_soru">
<div class="div_soru_wrapper">
<%#Eval("Subject")%>
<asp:RadioButtonList ID="RadioButtonList_secenekler" runat="server" Visible='<%# Eval("TypeId").ToString() == "1" %>'
DataSource='<%#Eval("Secenekler")%>' DataTextField='<%#Eval("OptionName")%>' DataValueField='<%#Eval("OptionId")%>'>
</asp:RadioButtonList>
<asp:CheckBoxList ID="CheckBoxList_secenekler" runat="server" Visible='<%# Eval("TypeId").ToString() == "2" %>'
DataSource='<%#Eval("Secenekler")%>' DataTextField='<%#Eval("OptionName")%>' DataValueField='<%#Eval("OptionId")%>'>
</asp:CheckBoxList>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
和代码隐藏:
SpAnketDataContext db = new SpAnketDataContext();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindRepeaterSorular();
}
}
protected void ImageButton_kaydet_OnCommand(object source, CommandEventArgs e)
{
}
private void BindRepeaterSorular()
{
int anket_id = 3;
var sorular = from soru in db.TableSurveyQuestions
where soru.SurveyId == anket_id
select new
{
soru.TypeId,
soru.Subject,
soru.QuestionId,
soru.SurveyId,
soru.QueueNo,
SurveyTitle = soru.TableSurvey.Title,
TypeName = soru.TableSurveyQuestionType.TypeName,
Secenekler = from secenekler in soru.TableSurveyOptions
select new
{
secenekler.OptionId,
secenekler.OptionName,
secenekler.QuestionId,
}
};
Repeater_sorular.DataSource = sorular;
Repeater_sorular.DataBind();
}
我的问题:
我无法绑定(bind) datavaluefield 和 datatextfiled。如果我按照上面的定义写。我收到这个错误。
DataBinding: '<>f__AnonymousType1`8[[System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Collections.Generic.IEnumerable`1[[<>f__AnonymousT...' does not contain a property with the name 'OptionName'.
如何绑定(bind)值和文本。
谢谢。
最佳答案
该错误本身解释得很清楚:
does not contain a property with the name 'OptionName'
只需更改此设置(在 RadioButtonList
和 CheckBoxList
的声明中):
DataTextField='<%#Eval("OptionName")%>' DataValueField='<%#Eval("OptionId")%>'
致:
DataTextField="OptionName" DataValueField="OptionId"
就是这样,您不需要评估绑定(bind),只需指定属性的名称即可。其余代码看起来不错
根据请求,从 RadioButtonList
中获取所选项目:
<asp:GridView runat="server" OnRowCommand="grdProducts_RowCommand" ID="grdProducts">
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false"
CommandName="myLink" CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' Text="Button"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButtonList DataTextField="NestedValue" DataValueField="ID" runat="server" DataSource='<%# Eval("Nested") %>' ID="radios">
</asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Label runat="server" ID="lblMessage" />
隐藏代码:
protected void grdProducts_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName)
{
case "myLink":
var row = this.grdProducts.Rows[int.Parse(e.CommandArgument.ToString())];
var radios = row.FindControl("radios") as RadioButtonList;
this.lblMessage.Text += "<br/>" + radios.UniqueID;
this.lblMessage.Text += "<br/> dedede " + radios.SelectedValue;
break;
}
}
关于中继器中的 ASP.NET RadioButtonList?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11077534/
嗨,我对 visualforce 中继器控件感到头疼:
我的页面类型为日期字段“日期”,但我似乎无法让中继器按日期显示项目。 我的计划是有一个包含日期、主题和作者的表,并使用 jquery 插件按日期排序。 最佳答案 编辑:如果您将 DocumentTyp
我在这里尝试做的是编写一个函数repeat,它接受一个字符串和一个正整数 n 并返回该字符串重复 n 次。因此 repeat("fho", 3) 将返回字符串“hohoho”。但是,下面的测试程序运行
是否可以始终显示 ASP.NET 转发器的页眉和页脚,无论它是否包含数据? 我很清楚这个问题以前曾被想要显示某种信息性消息的人问过,但在我的情况下,这一切都是为了为客户提供填充相同 Repeater
我需要为我正在从事的 enyo 项目制作一个数据表,该项目最终将显示 Ajax 调用的结果。 This (公然从 ryanjduffy here 窃取)似乎是一个很好的起点,但是当我尝试从按钮事件(而
我们目前使用转发器在每行上显示输入字段、下拉列表、复选框和日历项。所需的功能是允许用户添加最多 10 个(这可能会通过 Web 配置更改)项目(每行)。 在转发器中列出这些是否合适,或者我是否以错误的
我希望一个 asp.net 转发器控件在它指向的实际数据被更新时自行更新。我不是在寻找发生按钮单击并且每次中继器(位于更新面板内)都绑定(bind)到数据源的解决方案。 例如:在我的页面加载中,我有这
我正在尝试用中继器复制以下内容: 页眉是固定的,页脚也由从数据源返回的值固定。我所做的是将报头从中继器中取出。并添加了滚动条的代码 由于页脚需要修复,我不确定如何使该行不滚动。 所以我创建了第二个中
我有一个函数,可以将保存我想要显示的数据的DIV的值写入cooke,cookie代码有效,切换代码有效,但是当页面刷新时,我可以获得中继器列表元素,迭代它们,确定该部分是否应该隐藏,但我不能使用可见,
我正在使用 ASP.NET Repeater显示 的内容.它看起来像这样:
我有一个中继器,如下所示, 现在,我想将 LinkButton 的 Text 值与以下内容绑定(bind
Wicket 有很多 AbstractRepeaters 的实现:ListView、DataView、GridView、Loop、PropertyListView 等。 就我个人而言,我发现很难确定哪
如果写了如下代码: Repeater { model: 10; delegate: Rectangle { width: 200; height: 20; color: "whit
这是我的中继器: " /> 我喂中继器 来自数据库的 4 行数据,前三行 是必要的,但最后一个不应该存在。我该怎么做? 最佳答
有一个 routerLink 可以为 config 提供的导航提供必要的路由。 它工作正常,如果它像下面那样完成: Home About
我一直在努力创建自己的带有文本和链接输入字段的自定义 Gutenberg 中继器 block 。我只见过像 this 这样的 ES5 示例和 this .近 8 个小时以来,我一直致力于创建自己的这些
我有一个转发器,可以直接列出来自与我的 Outlook 绑定(bind)的应用程序的电子邮件。我需要中继器列出文件夹名称,然后列出该文件夹中的每条消息。然而,我得到的是该文件夹中每条消息的文件夹名称都
我有一个绑定(bind)服务器端的中继器控件。它重复一系列的 div,并且这样做没有问题。我有一些按钮用于对中继器进行排序(最新的、排名最高的、随机的),这按其应有的方式工作。 我想通过使用 Ajax
我们目前在现场有设备运行 UltraVNC 作为 VNC 服务器。因为我们的现场设备具有不可路由的 IP 地址,所以我们选择使用 UltraVNC 中继器服务器。 VNC 在设备上启动,我们在连接到中
.keyup 和 .change 仅在第一个输入中触发,但在我添加新项目后不会触发。添加新字段时有没有办法触发 .keyup 和 .change ? http://jsfiddle.net/q8pco
我是一名优秀的程序员,十分优秀!