0 Replies - 259 Views - Last Post: 26 April 2019 - 08:26 AM Rate Topic: -----

#1 DarenR   User is offline

  • D.I.C Lover

Reputation: 602
  • View blog
  • Posts: 3,993
  • Joined: 12-January 10

how to dynamically add a row containing controls with on blur vb.net

Posted 26 April 2019 - 08:26 AM

I have an asp.net application front end vb.net back end

what they want is have a row dynamically added to a table when a text box is click off of (onblur)

the controls per row are a dropdownlist and a text box which the drop down list is populated via sql in the vb.net code behind


if anyone has some pointers or resources on how to accomplish this it would be greatly appreciated.

the dll must be loaded on every row

asp
  <asp:Panel runat="server" GroupingText="DOWNTIME REASONS" class="panelReasons" >
                  <asp:Table Width="100%" runat="server" id="reasonsTable">
                      <asp:TableRow runat="server">
                          <asp:TableCell runat="server">
                             <asp:Label runat="server" text="Reason"></asp:Label>
                          </asp:TableCell>   
                          <asp:TableCell runat="server">       
                              <asp:Label runat="server" text="Minutes"></asp:Label>
                          </asp:TableCell>
                      </asp:TableRow>
                        <asp:TableRow runat="server">
                            <asp:TableCell runat="server">         
                                <asp:DropDownList runat="server" ID="ddlReason"/>
                            </asp:TableCell>   
                            <asp:TableCell runat="server">       
                                <asp:TextBox ID="txtReasonMinutes" runat="server"  CssClass="textboxStyle3" OnTextChanged="txtReasonMinutes_OnTextChanged"></asp:TextBox>
                            </asp:TableCell>
                        </asp:TableRow>
                  </asp:Table>
             </asp:Panel>



vb.net -- doesnt fire on text change for some reason -- i even tried onblur
 Protected Sub txtReasonMinutes_OnTextChanged(sender As Object, e As EventArgs)
        Dim _reasonArguments As New LoadDropDowns
        Dim row As TableRow = New TableRow()
        Dim cell As TableCell = New TableCell()
        Dim cell2 As TableCell = New TableCell()
        Dim ddlReason As DropDownList = new DropDownList()
        Dim newtextBox As TextBox = New TextBox()
        
        For i As Integer = 0 To reasonsTable.Rows.Count()
            
       
        ddlReason = _reasonArguments.LoadDropDowns("HR",0)
        cell.Controls.Add(ddlReason)
        row.Cells.add(cell)

        newtextBox.ID = "txtReasonMinutes" + i
        cell2.Controls.add(newtextBox)
        row.Cells.add(cell2)
        reasonsTable.Rows.Add(row)
            
        Next
       
        
    End Sub


Is This A Good Question/Topic? 0
  • +

Page 1 of 1