locked
Extracting Record from Form View RRS feed

  • Question

  • User564995064 posted

    I have an EditItemTemplate with form data in it.  The submit date is in a label.  The code below works except for the submit date.  Any idea what I am doing wrong?

                try
                {
                    Record formData = new Record();
    
                    txt = fv.FindControl(String.Format("txtLastname{0}", formMode)) as TextBox;
                    formData.LastName = txt.Text;
    
                    txt = fv.FindControl(String.Format("txtFirstname{0}", formMode)) as TextBox;
                    formData.FirstName = txt.Text;
    
                    txt = fv.FindControl(String.Format("txtMiddle{0}", formMode)) as TextBox;
                    formData.MI = txt.Text;
    
                    DateTimePicker dtp = fv.FindControl(String.Format("dtpDob{0}", formMode)) as DateTimePicker;
                    formData.BirthDate = dtp.Value;
    
                    Label lblDateSubmit = fv.FindControl(String.Format("lblSubmitDate{0}", formMode)) as Label;
                    formData.DateSubmission = DateTime.Parse(lblDateSubmit.Text.ToString());
    
                    return formData;
                }

    html:
                        <td>
                            <asp:Label ID="lblSubmitDate" runat="server" Text='<%# Eval("date_submit")%>'></asp:Label>
                        </td>

    Originally I had the html as:

    <td>
       <%# Eval("date_submit")%>
    </td>

    but I thought I may need to add a label so I could reference it in the c# code.  As I step through the code, the submit date is blank.  It will not extract the record.

    Thanks for any assistance you can give!

    Wednesday, February 22, 2017 5:46 PM

Answers

  • User-22249651 posted

    Hi rhondadunn,

    According to your current code and description, I can't reproduce the problem, I'm willing to help you if you can provide more code.

    The problem may be the way you finding the "lblSubmitDate" control is invalid.

    You can find it through the way "fv.row.FindControl()".

    or:

    Hope this helps!

    Best Regards

    Stanly

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 23, 2017 9:43 AM