Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to access a DetailsView's ItemTemplate's TextBox in code behind? ASP.Net C#
    primarykey
    data
    text
    <p>I have a DetailsView with 1 of its field converted to TemplateField to be able to manipulate the InsertItemTemplate that contains a TextBox (cf: code below). The problem is that I cannot access to that TextBox Properties in my code behind... and I really don't get it :( Here is my aspx code (portion of it):</p> <pre><code>&lt;asp:DetailsView ID="_DetailsView" ClientIDMode="Static" runat="server" Height="50px" Width="125px" AllowPaging="True" AutoGenerateRows="False" DataKeyNames="IDUniv" DataSourceID="EntityDS" OnModeChanging="_OnModeChanging"&gt; &lt;Fields&gt; &lt;asp:TemplateField HeaderText="DateUpdateUniv" SortExpression="DateUpdateUniv" ConvertEmptyStringToNull="False"&gt; &lt;InsertItemTemplate&gt; &lt;asp:TextBox ID="TextBoxInsertItem" runat="server" Text='&lt;%# Bind("DateUpdateUniv") %&gt;'&gt;&lt;/asp:TextBox&gt; &lt;/InsertItemTemplate&gt; &lt;ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" /&gt; &lt;/Fields&gt; &lt;/asp:DetailsView&gt; &lt;asp:EntityDataSource ID="EntityDS"&gt; </code></pre> <p>and in the Page_LoadComplete event Handler I have something like this:</p> <pre><code>private void Page_LoadComplete(object sender, EventArgs e) { if (_DetailsView.HasControls()) { Control _InsertDate = _DetailsView.FindControl("TextBoxInsertItem") as TextBox; if (_InsertDate != null) { _InsertDate.Text = "something"; } } } </code></pre> <p>but the following code is wrong: _DetailsView.FindControl("TextBoxInsertItem") and also this doesn't work: _InsertDate.Text = "something";</p> <p>I found an interesting article, but still...: <a href="http://www.devproconnections.com/article/aspnet2/getting-under-the-detailsview-control" rel="nofollow">http://www.devproconnections.com/article/aspnet2/getting-under-the-detailsview-control</a></p> <p>can someone help me find my path ? How to find this TextBoxInsertItem control and interact with it ? Thanks</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.
    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