locked
Extract the value of a DynamicControl in C# RRS feed

  • Question

  • User241697487 posted

    How do you read the value of a DynamicControl that is in a FormView template.

     

    The HTML:

    <span class="fv-header">Weight</span>

    <br />

    <asp:DynamicControl runat="server" ID="dynInsertWeight" DataField="Weight" Mode="Insert" ValidationGroup="Insert" />

    <br />

    <br />

    <span class="fv-header">H2SO4</span>

    <br />

    <asp:DynamicControl runat="server" ID="dynInsertH2SO4" DataField="H2SO4" Mode="Insert" ValidationGroup="Insert" />

    <br />

    <br />

    <span class="fv-header">NAOH</span>

    <br />

    <asp:DynamicControl runat="server" ID="dynInsertNAOH" DataField="NAOH" Mode="Insert" ValidationGroup="Insert" />

    <br />

     

    The ISSUE:

    I need to get the values from these three DynamicControls to calculate two other values that need to be saved to the database with these.

     

    The CODE:

    I have tried converting it to a textbox to extract the value (as shown below), but Visual Studio calls me nasty names when I do this…

     

          TextBox WT = (TextBox)frmWaterSampleDetails.FindControl("dynEditWeight");

     

    I have also searched Google but have found nothing…yet. I also tried…

     

          DynamicControl WT = (DynamicControl)frmWaterSampleDetails.FindControl("dynEditWeight");

     

    …but cannot find a property of ‘WT’ that will give me the value.

     

    Any advice or help would be very appreciated.

    Wednesday, September 23, 2015 9:53 AM

Answers

All replies