I'm trying to build a dynamic web form using ASP.NET.
Basically I've defined all the fields for the form in the database.
When the aspx is launched, it will first grab those values from the 
SQL DB as an XML, then I'm using XSLT to display the form.
Here's the background VB code:

    Public Sub displayForm()
        Dim sqlconn As New Data.SqlClient.SqlConnection
        Dim sqlcmd As New Data.SqlClient.SqlCommand
        Dim myXR As System.Xml.XmlTextReader
        Dim xmldoc As New XmlDocument
        Dim strXMLHeaderTag As String

        Try
            sqlconn.ConnectionString = Application("SQLConnStr")
            sqlconn.Open()

            sqlcmd.Connection = sqlconn
            sqlcmd.CommandText = "SELECT * FROM tblFormField Field 
ORDER BY Field.FieldOrder FOR XML AUTO, ELEMENTS"

            myXR = sqlcmd.ExecuteXmlReader()
            myXR.MoveToContent()

            'Because XMLDOC will only accept well-formatted XML 
string: XML wrapped within 1 top-root-tag
            strXMLHeaderTag = "<Top>"
            While Not myXR.EOF
                strXMLHeaderTag &= myXR.ReadOuterXml
            End While
            strXMLHeaderTag &= "</Top>"

            xmldoc.LoadXml(strXMLHeaderTag)
            Dim xslTran As XslTransform = New XslTransform
            xslTran.Load(Server.MapPath("test.xslt"))

            Dim sw As StringWriter
            sw = New StringWriter
            xslTran.Transform(xmldoc, Nothing, sw)

            Response.Write(sw.ToString)

        Catch exp As Exception
            Response.Write("Error in opening DB! index.displayform() " 
& exp.ToString)
        End Try
    End Sub

And this is the XSLT:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:template match="/">
  <table border="0">
    <xsl:for-each select="Top/Field">
      <tr>
        <xsl:variable name="fieldname" select="FieldName" /> 
        <xsl:variable name="fieldorder" select="FieldOrder" />
        <td><xsl:value-of select="NameDisplay"/>: </td>
        <td><INPUT id="txt{$fieldorder}" style="WIDTH: 190px; HEIGHT: 
22px" size="29" name="{$fieldname}"/></td>
      </tr>
    </xsl:for-each>
  </table>
</xsl:template>
</xsl:stylesheet>

Everything is okay until this point. It can display the form 
correctly.
However, I'm confused as how to grabs the user-input values from the 
textbox?
Because when user click the "Submit" button, back to the VB code, in 
the Submit_Click() function, I'm supposed to get the value of each 
textbox. But then, I can't simply just do "textboxname.Text", because 
the name of the textbox itself is only defined during run-time (in the 
XSLT)!

And how can I make an iteration to make sure that I get all the 
textboxes (Note that the number of textboxes in the form varies 
depending on how many fields I've defined in the DB).

Can anybody help? Thanks a lot!

Adrian




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to