0 Replies - 444 Views - Last Post: 02 May 2019 - 07:36 AM Rate Topic: -----

#1 DarenR   User is offline

  • D.I.C Lover

Reputation: 613
  • View blog
  • Posts: 4,043
  • Joined: 12-January 10

how does one populate dynamic selects that are created on row create

Posted 02 May 2019 - 07:36 AM

issue:
i have a javascript function which dynamically adds rows with controls in them.
one control is a select

i am able to fill the 1st select because the id is static from the code behind

added rows take that id and ad a number to the end like

ddl1
ddl2
ddl3
and so on

question:
so how do i use that code behind to fill the selects that are dynamically created on row add?


javascript code for row add:

 $(document).ready(function () {  
            $(document).on("click", ".classAdd", function () { //
                var rowCount = $('.data-hour-reason').length + 1;  
                var reasonsdiv = '<tr class="data-hour-reason">' +  
                    '<td><select name="ddlReason' + rowCount + '" class="form-control ddlReason01" id="ddlReason' + rowCount + '"/></td>' +  
                    '<td><input type="text" name="txtMinutes' + rowCount + '" class="form-control minutes01" /></td>' +  
                    '<td><button type="button" id="btnAdd" class="btn btn-xs btn-primary classAdd">Add More</button>' +  
                    '</tr>';  
                $('#Reasonstbl').append(reasonsdiv); // Adding these controls to Main table class  
            });  
        });



vb.net code behind:

Dim _reasonArguments As New LoadDropDowns
        
        ddlReason.DataSource = _reasonArguments.LoadDropDowns("HR", 0)
        ddlReason.DataTextField = "txtDTArgumentsName"
        ddlReason.DataValueField = "DowntimeArgumentsID"
        ddlReason.DataBind()



i guess what i am asking is how do i change the id of the vb code behind to match the select id

Is This A Good Question/Topic? 0
  • +

Page 1 of 1