Here’s an odd situation. In my FormView control, I put a <table> for layout. With the rows (<tr>) I added IDs and runat="server". The insert only saved some of the data, which I thought was odd. I looked to see why those fields stored and others didn’t, and the only difference was I hadn’t added the IDs or runat="server" to the <tr>s. Removing the “runat” allowed the insert to work normally.
I assume this has something to do with the way the rows are initialized versus when the control or FormView is initialized. Any thoughts why this happens? For now, I’m removing the IDs from the table rows.
You’re on the right track in your thinking.
The
FormViewonly looks at top-level controls. If you embed one of your intended input controls inside of another server-side control, theFormViewdoesn’t see it (it’s been hidden inside the outer control). Even in your code-behind you’d have to use theFindControlmethod to get the input tag out of the server-side<tr>Thus, if you had this:
The only thing the
FormViewsees is the top-level element (the<tr>). You wouldn’t even see theTextBoxin your codebehind unless you did this:So my suggestion would be to leave off the “runat” and “ID” tags from the
<tr>elements; since they are just for display purposes, you don’t really need them at the server-side.I hope that clears things up a little.