About Boster Sibande Expertise I can answer questions in the following areas: ASP.Net, VB.Net, C#.Net, Microsoft Access and SQL Server. These are the technologies I use in my day-to-day work. As such, I am very confident and happy to assist
Experience I have two years experience with ASP.Net
Organizations UNDP
Education/Credentials Currently studying MSc. in IT
Expert: Boster Sibande Date: 6/16/2006 Subject: Dynamic runtime textboxes and inserting these retrived boxes value into database.
Question First of all thanks for ur generosity to help me...
I have already applied the counter but problem is how to insert it into the database.
suppose i have these values which is generating automatically....
employeeid1
employeeid2
so on....in a text box....
<%
dim strSQL2
dim strdept1
strdept1 = Request.Form("department")
strSQL2 = "SELECT * from emp_detail where department='" & strdept1 & "'"
objRS.Open strSQL2, adoConn
%>
Here i am getting the values with counter values but now how to insert these values in the next page....
how to insert
<input name=gurmeet1 values=john>
<input name=gurmeet2 values=boster>
<input name=gurmeet3 values=walls>
I normally take the value through request.form("fieldname")
so how to first take all the dynamic retrieved text boxes value into the variable dynamically...becasue how many values will come exactly it is not known in advance...
-------------------------
Followup To
Question -
I am first retrieving value dynamically in textboxes, which are also generated dynamically..it is also generating checkboxes and base on the click of these checkboxes those records i want to enter into the database.
step1: Based on the combo box i am first retrieving value from another tableo of database.
step2: Dynamic records are generated along with textboxes....but all the texboxes in which i am retrieving data are of the same name. so when i am inserting data based on the check boxes which also i am retrieving dynamically then all values goes to the same row....
-------------------------------------------------
<%
Do While Not objRS.eof
response.write "<TR><TD align=center height=20 bgcolor=E1F0FD>" & "<font size=2 face=arial color=#016A99>" & "<INPUT NAME=employeeid value='" & objRS("employeeid") & "' SIZE=8 style='padding:2px; color: #016A99; border: 1px solid #016A99; text-align:center; background-color: #E1F0FD; font-family:Verdana; font-size:8pt;' tabindex=1 maxlength=8>" & "</TD>" & "</font>"
response.write "<TD align=center height=20 bgcolor=E1F0FD>" & "<font size=2 face=arial color=#016A99>" & "<INPUT NAME=emp_name value='" & objRS("emp_name") & "' SIZE=25 style='padding:2px; color: #016A99; border: 1px solid #016A99; text-align:center; background-color: #E1F0FD; font-family:Verdana; font-size:8pt;' tabindex=1 maxlength=8>" & "</TD>" & "</font>"
response.write "<TD align=center height=20 bgcolor=E1F0FD>" & "<font size=2 face=arial color=#016A99>" & "<INPUT NAME=level value='" & objRS("level") & "' SIZE=8 style='padding:2px; color: #016A99; border: 1px solid #016A99; text-align:center; background-color: #E1F0FD; font-family:Verdana; font-size:8pt;' tabindex=1 maxlength=8>" & "</TD>" & "</font>"
response.write "<TD align=center height=20 bgcolor=E1F0FD>" & "<font size=2 face=arial color=#016A99>" & "<INPUT type=checkbox name=assigned value=Yes>" & "</font>" & "<br></TD></TR>"
objRS.movenext
Loop
%>
Problem is how to insert these values into the table...actually a user select a particular records based by just checking the check box. But right now all records are inserted into the same rows.....
Answer -
You are having the same name on textboxes because you are not changing the name of a control when you move from one record to another. Therefore, the solution is to make the NAME of control dynamic just as the value.
i.e. instead of
<%
Do While Not objRS.eof
..."<INPUT NAME=employeeid....
%>
Declare a record counter and change the code to
<%
Do While Not objRS.eof
counter=counter+1
..."<INPUT NAME=employeeid" & counter & ...
%>
Thanks,
Boster.
Answer Create a hidden integer field and assign objRS.RecordCount to it. The hidden field will help you to keep the number of controls (e.g. text boxes) on the form. The other good thing is that the hidden field can be accessible in other pages using request.form.