aislancezar
New Member
I am not able to retrieve the value of dynamically added text box to table. Kindly help me to find mistake on this code.<BR><BR><BR>Error <BR><BR>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <BR><BR>Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index<BR><BR>Source Error: <BR><BR><BR>Line 52: Dim txtBox As New TextBox()<BR>Line 53: <BR>Line 54:txtBox = CType(Table1.Rows(1).FindControl ("txtBox1"), TextBox)<BR>Line 55: Response.Write(txtBox.Text)<BR>Line 56: <BR> <BR><BR>Source File: c:inetpubwwwrootDragDropWebForm2.aspx.vb Line: 54 <BR><BR>Stack Trace: <BR><BR><BR>[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.<BR>Parameter name: index]<BR> System.Web.UI.ControlCollection.get_Item(Int32 index)<BR> System.Web.UI.WebControls.TableRowCollection.get_I tem(Int32 index)<BR> DragDrop.WebForm2.Button1_Click(Object sender, EventArgs e) in c:inetpubwwwrootDragDropWebForm2.aspx.vb:54<BR> System.Web.UI.WebControls.Button.OnClick(EventArgs e)<BR> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument)<BR> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)<BR> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)<BR> System.Web.UI.Page.ProcessRequestMain()<BR><BR> <BR><BR><BR><BR>Source Code<BR><BR>Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR> 'Put user code to initialize the page here<BR> If Not Page.IsPostBack Then<BR> Dim IdWidth As New Unit("5%")<BR> Dim QWidth As New Unit("95%")<BR> Dim Height As New Unit("20%")<BR> Dim myARow As New TableRow()<BR> Dim myACell1 As New TableCell()<BR> Dim myACell2 As New TableCell()<BR> Dim myACell3 As New TableCell()<BR> myACell1.Width = IdWidth<BR> myACell2.Width = QWidth<BR> myARow.Cells.Add(myACell1)<BR> myARow.Cells.Add(myACell2)<BR> myARow.Cells.Add(myACell3)<BR> Dim txtBox As New TextBox()<BR> Dim hidtxtBoxValue As New HtmlInputHidden()<BR> Dim hidtxtQW As New HtmlInputHidden()<BR> txtBox.ID = "txtBox" & 1<BR> txtBox.Width = QWidth<BR> myACell2.Controls.Add(txtBox)<BR> Table1.Rows.Add(myARow)<BR> <BR> End If<BR><BR> End Sub<BR><BR> Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click<BR> Dim txtBox As New TextBox()<BR><BR> txtBox = CType(Table1.Rows(1).FindControl("txtBox1"),TextBox)<BR> Response.Write(txtBox.Text)<BR><BR> End Sub<BR>I'm dynamically adding a table to my page - the table contains checkboxes and I can't seem to figure out how to access them to see if they have been checked. I'm starting to lose it. Any advice?