I have reviewed several answers that all seem to indicate that using the format of [textboxID].Text should allow me to reference the input data when I am in the code behind, but this does not hold true for me. My example is as follows:
/** .aspx markup file **/ '''
<asp:ListView ID="ListViewWorkTypes" runat="server" InsertItemPosition="LastItem" >
<LayoutTemplate>
<table id="TypeRecords" runat="server" >
<tr id="TR1" runat="server" >
<td id="Td1" runat="server" >
<table runat="server" id="TypePlaceholder" >
<tr id="Tr2" runat="server" >
<td id="Td10" hidden="hidden" runat="server">Task Name</td>
<td id="Td20" runat="server">PhaseId</td>
<td id="Td30" runat="server">DeptId</td>
<td id="Td11" runat="server">Initial Value</td>
<td id="Td21" runat="server">Order</td>
<td id="Td23" runat="server">Math Operator</td>
<td id="Td31" runat="server">Option Value 1</td>
<td id="Td41" runat="server">Option Value 2</td>
<td id="Td51" runat="server">Option Value 3</td>
<td id="Td61" runat="server">Option Value 4</td>
<td id="Td71" runat="server">Option Value 5</td>
</tr>
<tr runat="server" id="itemPlaceholder">
</tr>
<tr runat="server">
<td runat="server" colspan="2">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Link" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Link" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
<InsertItemTemplate>
<tr id="NewWorkTaskRow">
<td id="NewTaskName">
<asp:Label runat="server" ID="TaskNameLabel" Visible="true" AssociatedControlID="TaskNameTextBox" Text="Task Name"/>
<asp:TextBox ID="TaskNameTextBox" runat="server" Visible="true" Text='<%# Bind("Name") %>' /><br />
</td>
<td id="NewPhase">
<asp:Label runat="server" ID="PhaseLabel" Text="Phase" AssociatedControlID="PhaseDropDown"/>
<asp:DropDownList ID="PhaseDropDown" runat="server" DataSourceID="SqlDataPhase" DataTextField="PhaseName" DataValueField="PhaseID" AppendDataBoundItems="true" >
<asp:ListItem Text="Choose Phase" Value="" Selected="False"></asp:ListItem>
</asp:DropDownList>
</td>
<td id="NewFunctionalArea">
<asp:Label runat="server" ID="DeptLabel" Text="Fuctional Area" AssociatedControlID="DeptDropDown" />
<asp:DropDownList ID="DeptDropDown" runat="server" DataSourceID="SqlDataDept" DataTextField="Dept" DataValueField="DeptId" AppendDataBoundItems="True">
<asp:ListItem Text="Choose Functional Area" Value="" Selected="True"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Label runat="server" ID="BaseValueLabel" AssociatedControlID="BaseValueTextBox" Text="Base Value" />
<asp:TextBox ID="BaseValueTextBox" runat="server" Text='<%# Bind("BaseValue") %>' /><br />
</td>
<td>
<asp:Label runat="server" ID="OrderLabel" AssociatedControlID="OrderTextBox" Text="Order" />
<asp:TextBox ID="OrderTextBox" runat="server" Text='<%# Bind("ordr") %>' /><br />
</td>
<td>
<asp:Label runat="server" ID="MathOperatorLabel" AssociatedControlID="MathOperatorTextBox" Text="Math Operator" />
<asp:TextBox ID="MathOperatorTextBox" runat="server" Text='<%# Bind("MathOperator") %>' /><br />
</td>
<td>
<asp:Label runat="server" ID="Opt1Label" AssociatedControlID="Opt1TextBox" Text="Option Value" />
<asp:TextBox ID="Opt1TextBox" runat="server" Text='<%# Bind("Opt1") %>' /><br />
</td>
<td>
<asp:Label runat="server" ID="Opt2Label" AssociatedControlID="Opt2TextBox" Text="Option Value" />
<asp:TextBox ID="Opt2TextBox" runat="server" Text='<%# Bind("Opt2") %>' /><br />
</td>
<td>
<asp:Label runat="server" ID="Opt3Label" AssociatedControlID="Opt3TextBox" Text="Option Value" />
<asp:TextBox ID="Opt3TextBox" runat="server" Text='<%# Bind("Opt3") %>' /><br />
</td>
<td>
<asp:Label runat="server" ID="Opt4Label" AssociatedControlID="Opt4TextBox" Text="Option Value" />
<asp:TextBox ID="Opt4TextBox" runat="server" Text='<%# Bind("Opt4") %>' /><br />
</td>
<td>
<asp:Label runat="server" ID="Opt5Label" AssociatedControlID="Opt5TextBox" Text="Option Value" />
<asp:TextBox ID="Opt5TextBox" runat="server" Text='<%# Bind("Opt5") %>' />
</td>
<td>
<asp:LinkButton ID="InsertButton" runat="server" OnClick="InsertType" Text="Insert" ></asp:LinkButton>
</td>
</tr>
</InsertItemTemplate>
'''
/** Code Behind **/ ''' protected void InsertType(object sender, EventArgs e) { string Name = ""; int BaseValue = 0; bool LOE; int ordr; char operation; int Opt1 = 0; int Opt2 = 0; int Opt3 = 0; int Opt4 = 0; int Opt5 = 0; int TypeID = 0;
string strtypecon = WebConfigurationManager.ConnectionStrings["DefaultEstimateConnection"].ConnectionString;
SqlConnection typeconx = new SqlConnection(strtypecon);
SqlCommand TypeCmd = new SqlCommand()
{
Connection = typeconx
};
/*** Attempted with the aforementioned TextBox ID reference ***/
Name = TaskNameTextBox.Text;
/*** Err msg: TaskNameTextBox does not exist in current context ***/
/*** Attempted with Request form ***/
Name = Request.Form["TaskNameTextBox"];
/** Checkpoint at this point of the process indicates a null value for Name **/
ListViewWorkTypes.FindControl("TaskNameTextBox").ToString();
TypeCmd.Parameters.AddWithValue("@Name", Name);
'''
This did not seem different from the other code I had seen on this site that had reportedly worked.