通过提交按钮将ASP.NET Repeater中的DataBinder值传递给数据库

时间:2013-07-26 10:09:24

标签: repeater radiobuttonlist databinder

如何将此值传递给<%#DataBinder.Eval(Container, "DataItem.QuestionsText")%>,提交给提交码:database.InsertUpdate(String.Format("CALL spSurveyAnswer_Insert('{0}', '{1}','{2}');", selectValue1, txtFeedBack.Text, IneedToPassitHere )), 顺便说一句,dataBinder存在于下面的代码中:

 <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">

     <HeaderTemplate>
         <table class="tblcolor">
             <tr class="rowcolor">
             <b>
             </b>
             </tr>
</HeaderTemplate>

     <ItemTemplate>
<tr class="tblrowcolors">
<td>  <%#DataBinder.Eval(Container, "DataItem.QuestionsText")%></td>


     <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">

   <asp:ListItem Text="1" selected="true" Value="Item1"/> 
   <asp:ListItem Text="2" Value="Item2"/>
   <asp:ListItem Text="3" Value="Item3"/> 
   <asp:ListItem Text="4" Value="Item4"/> 
   <asp:ListItem Text="5" Value="Item5"/> 



    </asp:RadioButtonList>

提前致谢...

1 个答案:

答案 0 :(得分:0)

我通过添加标签来解决这个问题,以保存值:

<asp:Label ID="Label1" runat="server" Text='<%# Eval("Survey_Questions_ID")%>' Visible="false"></asp:Label>

然后在转发器功能中调用此标签,例如:

Label lbl = (Label)item.FindControl("Label1");
Response.Write(lbl.Text);

干杯