ASP.NET and For Each Loops

kuncen

New Member
I have a form with a variable number of checkboxes. For each box is checked, I want the correspondidng textbox data submitted to my table. <BR><BR>But the ASP.NET is not acceptin the ASP code: for intloop=1 to request.form(item).count <BR><BR>What is the correct way to write a for loop in ASP.NET? <BR><BR>My code: <BR><BR>x=1 <BR>For Each Item in Request.Form <BR><BR>if request.form("wok"&x) <> "" then <BR><BR>myCommand = new SQLCommand("INSERT into SQLAdd (NAME, lastname) VALUES ('" & Request.Form("wok11") & "', '" & Request.Form("wok21") & "')", myConnection) <BR><BR>end if <BR>x +=1 <BR>nextHow do I assign multiple values to an ASP.NET checkbox?<BR><BR>In VBScript I did it like this<BR><BR><input type="checkbox" value=http://aspmessageboard.com/archive/index.php/"<%=rs("field1")%><%=rs("field2")%>"><BR><BR> And then I would parse it on the next page.<BR><BR><BR>But with the ASP.NET I have been unable to change its value from on.<BR><BR>If I put a value="whatever" in the tag, it becomes a <span> element.<BR><BR>Any ideas?<BR>What are you using to create the checkboxes...a checkbox list or a placeholder??? Are you using Autopostback, going to a new page? There are different ways you can approach this depending on your approach to the situation.I'm guessing you are not using code-behind.<BR><BR>try using:<BR><asp:checkboxlist runat="server" id="cbl1" /><BR><BR>in your code, try:<BR><BR>-pseudocode:<BR>open database<BR>get recordset into rs(use dataset...much easier for databinding)<BR><BR>cbl1.datasource=rs.table(0).defaultview<BR><BR>There are different ways in which you can approach this. I can't tell which approach you are taking from the way you are describing the problems. If you want, you can send me zipped files of your aspx pages and I'll take a look for you and let you know what you are doing wrong.<BR><BR>Xay<BR>
 
Back
Top