在后台如何获取Repeater控件中绑定的值 如<%#Eval("tiid") %>的值
 <%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="AddTestContent.aspx.cs" Inherits="ZaiXianKaoShi.AddTestContent" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <form runat="server">
        <%--只能在详情中添加试题内容(此页面已得到考试编号)--%>
        <%--考试编号:--%>
        <%--题库id:
        分值:--%>
        <div class="portlet box purple">

                            <div class="portlet-title">

                                <div class="caption"><i class="icon-cogs"></i>题目信息显示</div>



                            </div>

                            <div class="portlet-body">

                                <div id="sample_3_wrapper" class="dataTables_wrapper form-inline" role="grid">
                                    <div class="row-fluid">
                                        <div class="span6">
                                        <div class="dataTables_length" id="sample_3_length">
                                            <label>
                                                <div id="s2id_autogen3" class="select2-container m-wrap small">
                                                <a href="javascript:void(0)" onclick="return false;" class="select2-choice" tabindex="-1">
                                                      <abbr class="select2-search-choice-close" style="display:none;"></abbr>  
                                                     <div>
                                                         <b></b>

                                                     </div>

                                                </a>

                                                   </div>
                                                <select tabindex="-1" class="m-wrap small select2-offscreen" aria-controls="sample_3" size="1" name="sample_3_length">
                                                         <option selected="selected" value="5">5</option>
                                                         <option value="10">10</option>
                                                         <option value="20">20</option>
                                                         <option value="-1">All</option>

                                                 </select> 每页显示行数
                                            </label>

                                        </div>

                                                           </div>
                                        <div class="span6"><div id="Div2" class="dataTables_filter"><label>搜索: <input class="m-wrap small" aria-controls="sample_2" type="text"></label></div></div>

                                    </div>

                                     <table aria-describedby="sample_3_info" class="table table-striped table-bordered table-hover dataTable" id="sample_3">

                                    <asp:Repeater id="Repeater2" runat="server">
                                        <HeaderTemplate>
                                            <tr>
                                                <th>题库编号</th>
                                                <th>科目编号</th>
                                                <th>试题内容</th>
                                                <th>待选答案</th>
                                                <th>正确答案</th>
                                                <%--<th>分值</th>--%>
                                                <th>添加到试卷</th>
                                            </tr>
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <tr>
                                                <td><%#Eval("tiid") %></td>
                                                <td><%#Eval("subid") %></td>
                                                <td><%#Eval("content") %></td>
                                                <td><%#Eval("answerS") %></td>
                                                <td><%#Eval("answer") %></td>
                                                <%--<td><input type="text" name="fen" id="fen" style="width:20px; height:12px" runat="server" value="10" />分</td>--%>
                                                <td>
                                                    <%--<a href="AddTestContent.aspx?tid=<%#Eval("tiid") %>&id=<%=Request["testid"] %>&subid=<%=Request["subid"] %>">添加</a>--%>
                                                    <input type="submit" value="添加" />
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:Repeater>

                                          </table>
                                    <div class="row-fluid">
                                        <div class="span6">
                                            <div id="sample_3_info" class="dataTables_info" runat="server" style="color:#f00">


                                            </div></div><div class="span6">
                                                <div class="dataTables_paginate paging_bootstrap pagination">
                                                    <ul>
                                                        <li class="prev disabled"><a href="#">← <span class="hidden-480">
                                                            Prev

                                                            </span></a></li>
                                                        <li class="active">
                                                            <a href="#">1</a></li><li><a href="#">2</a></li>
                                                        <li><a href="#">3</a></li><li class="next">
                                                            <a href="#"><span class="hidden-480">Next</span> → </a>

                                                                                  </li></ul></div></div></div></div>

                            </div>

                        </div>

    </form>
</asp:Content>

1个回答

太不伦不类了,要么你就全部服务器端控件,要么就全部客户端的
去掉最外层runat=server那个表单,改为客户端form,ttid那种值放入控件里面,提交就可以用Request对象获取了

                                        <ItemTemplate>
                                                                                <form method="post">
                                            <tr>
                                                <td><%#Eval("tiid") %><input type="hidden" name="tiid" value="<%#Eval("tiid") %>"/></td>
                                                <td><%#Eval("subid") %><input type="hidden" name="tiid" value="<%#Eval("subid") %>"/></td>
                                                <td><%#Eval("content") %><input type="hidden" name="tiid" value="<%#Eval("content") %>"/></td>
                                                <td><%#Eval("answerS") %><input type="hidden" name="tiid" value="<%#Eval("answerS") %>"/></td>
                                                <td><%#Eval("answer") %><input type="hidden" name="tiid" value="<%#Eval("answer") %>"/></td>

                                                <td>
                                                    <input type="submit" value="添加" />
                                                </td>
                                            </tr></form>
                                        </ItemTemplate>
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐