在Repeater的多重嵌套情况下,出现了无法将类型为“System.Data.DataRow”的对象强制转换为类型“System.Data.DataRowView的错误,解决办法如下:
<table style="width:100%;border:0;">
<asp:repeater id="Repeater1" runat="server">
<itemtemplate>
<tr style="font-family: 黑体; font-size: 100; color: #FFFFFF; background-color: #008080; font-weight: bold;"><td><%=GetChineseOrderByNumber()%>.<%# DataBinder.Eval(Container.DataItem, "Question_type_name")%></td>
<td><img src ="../images/plus.gif" align="right" style="cursor:pointer;" onclick ="if(this.src.indexOf('minus.gif') != -1) {this.src='../images/plus.gif';document.getElementById('tbSingleSelect').style.display='none';} else {this.src='../images/minus.gif';document.getElementById('tbSingleSelect').style.display='';}"/> </td>
</tr>
<tr ><td colspan=2>
<!-- 单选题处理 -->
<table id="tbSingleSelect">
<asp:repeater id="repSingleSelect" runat="server" datasource='<%#((DataRowView)Container.DataItem).Row.GetChildRows("rel_question_type")%>' >
<itemtemplate>
<tr class ="color1" style="font-family: 宋体, Arial, Helvetica, sans-serif; font-size: x-small; font-weight: bold; font-variant: small-caps">
<td><%# DataBinder.Eval(Container.DataItem, "[/"Disp_order/"]")%> .<%# DataBinder.Eval(Container.DataItem, "[/"Question_Text/"]")%> </td>
<td ><div id='div<%# DataBinder.Eval(Container.DataItem, "[/"Question_id/"]")%>'style="Display:inline">3333</div></td>
</tr>
<tr><td>
<table>
<asp:repeater id="repSingleSelectChild" runat="server" datasource='<%#((DataRow)Container.DataItem).GetChildRows("rel_question")%>'>
<itemtemplate>
<tr class ="color1" style="font-family: 宋体, Arial, Helvetica, sans-serif; font-size: x-small; font-weight: normal; font-variant: small-caps;">
<td>
<input type="radio" id='radio<%# DataBinder.Eval(Container.DataItem, "[/"Question_id/"]")%>_<%# DataBinder.Eval(Container.DataItem, "[/"Question_id/"]")%>' name='<%# DataBinder.Eval(Container.DataItem, "[/"Question_id/"]")%> 'οnclick="setOptionValue('div<%# DataBinder.Eval(Container.DataItem, "[/"Question_id/"]")%>','<%# DataBinder.Eval(Container.DataItem, "[/"Option_id/"]")%>')"/>
<%# DataBinder.Eval(Container.DataItem, "[/"Option_id/"]")%>.<%# DataBinder.Eval(Container.DataItem, "[/"Option_text/"]")%>
</td>
</tr>
</itemtemplate>
</asp:repeater>
</table>
</td>
</tr>
</itemtemplate>
</asp:repeater>
</table>
</td></tr>
</table>