Jagjit Saini

Jagjit Saini

  • NA
  • 196
  • 37.9k

Insert Record using Repeater

Mar 5 2022 1:21 PM

Hi

How to insert record from repeater

<asp:Repeater ID="rpQuestion" runat="server" >
     <ItemTemplate>
         <tr>
             <td>
                 <asp:HiddenField ID="hdfQId" runat="server" Value='<%# Eval("QuestionID") %>' />
                 <asp:Literal ID="ltrlNum" Text="<%# Convert.ToString(Container.ItemIndex + 1) %>" runat="server"></asp:Literal>
             </td>
             <td>
                 <asp:Literal ID="ltrlLeadQuestion" runat="server" Text='<%# Eval("LeadQuestion1") %>'></asp:Literal>
             </td>
             <td>
                 <asp:TextBox runat="server" ID="txtAns" class="form-control" TextMode="MultiLine" Rows="4" ></asp:TextBox>
             </td>
         </tr>
     </ItemTemplate>
</asp:Repeater>
public int AddLeadInput(LeadInput objLeadInput)
{
    try
    {
        int ack = 0;
        context.Connection.Open();
        context.Transaction = context.Connection.BeginTransaction();

        context.LeadInputs.InsertOnSubmit(objLeadInput);
        context.SubmitChanges();

        context.Transaction.Commit();
        ack = objLeadInput.LeadInputID;
        return ack;
    }
    catch (Exception ex)
    {
        context.Transaction.Rollback();
        throw ex;
    }
}
BALLeadInput bALLeadInput = new BALLeadInput();
LeadInput leadInput = new LeadInput();

Thanks


Answers (2)