Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can we have an Editable Grid in ASP ??

Status
Not open for further replies.

vikramonline

Programmer
Oct 14, 2003
186
IN
I have a master detail form. Where we enter one master detail and many child details.

Now the no of child details is not known.It can be 1 or 100.


How can we tackle such a problem in ASP ?? Please suggest.
 
It can be done by creating an HTML form dynamically.....

Code:
<%
set rs = cn.execute("SELECT * FROM myTable WHERE field1 = " & someValue)

do while not rs.eof
  htmlOut = htmlOut &_
   "<tr>"&_
   "<td><input name='field1Name_" & rs("pKey") & "' value='" & rs("field1Val") & "'></td>"&_
   "<td><input name='field2Name_" & rs("pKey") & "' value='" & rs("field2Val") & "'></td>"&_
   "</tr>"
  rs.movenext
loop
%>


<form name="myForm">
<table>
<%=htmlOut%>
</table>
</form>

then on your form handler page, just look at the PK value for the field to do your updates...

Code:
for each item in request.form
  fieldName = left(item, inStr(item,"_") - 1)
  pkVal = right(item, len(item) - inStr(item,"_") + 1)
  sqlStr = "UPDATE myTable SET " & fieldName & " = '" & request(item) & "' WHERE pKey = " & pkVal
  cn.execute(sqlStr)
next


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Thanx Wolf and Shetty for ur input.
I am a bit busy with some other project.As and when I get time I will check and let u know.

Thanx Again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top