Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing FindControl to find the contents of an HTML control
    text
    copied!<p>I've got this code in the code-behind on my page, which works perfectly fine for a repeater:</p> <pre><code> protected void AcctAssnRepeater_ItemCommand(object source, RepeaterCommandEventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PBRConnectionString"].ConnectionString); con.Open(); { string str10 = ((HtmlInputText)e.Item.FindControl("txtFlgUpdatedOn")).Value; } } </code></pre> <p>I'm trying to do something similar on another page, but it is telling me that "item" isn't valid:</p> <pre><code> protected void btnSubmit_OnClick(object sender, EventArgs e) { string str10 = ((HtmlInputText)e.Item.FindControl("txtDtSentToCIS")).Value; } </code></pre> <p>I'm still a C# n00b, can anyone tell me how to reference the value inside this control? Both pages have a runat="server" on the aspx side, so I would expect that there's a way to do it, I'm sure my syntax just needs adjusting.</p> <p>Thanks!</p> <p>EDIT: Here's a piece of the aspx. Maybe I should note that it's all inside a Tab Control.</p> <pre><code> &lt;div style="width:430px;border:1px solid blue;float:left;"&gt; &lt;asp:Panel ID="Panel3" runat="server" Height="220px" style="float:left; margin-left: 19px" Width="410px"&gt; &lt;table&gt; &lt;tr&gt; &lt;td width="210px"&gt;BIL Name:&lt;/td&gt; &lt;td width="200px"&gt;&lt;asp:textbox id="txtCISName" runat="server"&gt;&lt;/asp:textbox&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="210px"&gt;Date Sent To BIL:&lt;/td&gt; &lt;td width="200px"&gt;&lt;input type="text" id="txtDtSentToCIS" class="datepicker" name="txtDtSentToCIS" runat="server" style="height: 14px; width: 70px" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="210px"&gt;BIL Sign Off Received:&lt;/td&gt; &lt;td width="200px"&gt;&lt;asp:DropDownList ID="cboCISSignOff" runat="server" Height="16px" AutoPostBack="True" onselectedindexchanged="chkCISSignOff_CheckedChanged"&gt; &lt;asp:ListItem&gt;N&lt;/asp:ListItem&gt; &lt;asp:ListItem&gt;Y&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="210px"&gt;&lt;asp:Label runat="server" Text="BIL Response:" ID="CISResp" /&gt;&lt;/td&gt; &lt;td width="200px"&gt;&lt;asp:textbox id="txtCISResponse" runat="server" textmode="MultiLine" rows="9" Width="180px"&gt;&lt;/asp:textbox&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/asp:Panel&gt; &lt;/div&gt; </code></pre>
 

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