Note that there are some explanatory texts on larger screens.

plurals
  1. POPopulating a variable with DetailsView textbox data value
    primarykey
    data
    text
    <p>When an ASP.Net DetailsView data is first displayed, can you tell me how to populate the variable shown in this coding?</p> <p>I already tried this in the code-behind file but was shown an error that:</p> <pre><code>Object reference not set to an instance of an object. </code></pre> <p>This is the coding:</p> <pre><code>Protected Sub DetailsViewDetails_DataBound(sender As Object, e As EventArgs) Handles DetailsViewDetails.DataBound Dim txtOriginalRegistrationFee As TextBox If DetailsViewDetails.CurrentMode = DetailsViewMode.Edit Then txtOriginalRegistrationFee = FindControl("TextBoxRegistrationFee") If String.IsNullOrEmpty(txtOriginalRegistrationFee.Text) = False Then MsgBox(txtOriginalRegistrationFee) End If End If End Sub </code></pre> <p>This is from the aspx file:</p> <pre><code>&lt;asp:TemplateField HeaderText="RegistrationFee" SortExpression="RegistrationFee"&gt; &lt;EditItemTemplate&gt; &lt;asp:TextBox ID="TextBoxRegistrationFee" runat="server" Text='&lt;%# Eval("RegistrationFee") %&gt;'&gt;&lt;/asp:TextBox&gt; &lt;/EditItemTemplate&gt; &lt;InsertItemTemplate&gt; &lt;asp:TextBox ID="TextBoxRegistrationFee" runat="server" Text='&lt;%# Bind("RegistrationFee") %&gt;'&gt;&lt;/asp:TextBox&gt; &lt;/InsertItemTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="LabelRegistrationFee" runat="server" Text='&lt;%# Bind("RegistrationFee", "{0:c}") %&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle ForeColor="Blue" /&gt; &lt;/asp:TemplateField&gt; </code></pre> <p><strong>* Update *</strong></p> <p>I tried using this coding updated based on your help but still get the "Object reference not set to an instance of an object." error when clicking the edit button of the DetailsView.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload