Home All Groups Group Topic Archive Search About

FormView problem with Templates and Tables

Author
13 Oct 2006 7:49 PM
~john
I've got a FormView with Templates used to edit records. I was using
<asp:Parameters> to send off my data back to the Update method of my
class. Everything worked as expected until I through in an <asp:Table>
to position my TextBoxes inside my FormView. None of the
<asp:Parameters> were getting set. I changed the parameter type of
<asp:ControlParameters> and that seemd to fix it.... but I'm not clear
why it fixed it. Here's my revised code.





<asp:ObjectDataSource
        ID="ObjectDataSource1"
        runat="server"
        TypeName="MyClass"
        SelectMethod="GetMyRecords"
        UpdateMethod="UpdateMyRecord">
        <UpdateParameters>
            <asp:ControlParameter Name="MyID"
ControlID="FormView1$MyIDTextBox" PropertyName="Text" />
        </UpdateParameters>
</asp:ObjectDataSource>

<asp:FormView ID="FormView1" runat="server"
DataSourceID="ObjectDataSource1">
        <EditItemTemplate>
            <asp:Table ID="Table1" runat="server" >
                <asp:TableRow>
                    <asp:TableCell>
                       <asp:TextBox ID="MyIDTextBox" runat="server"
Text='<%# Bind("MyID") %>'>
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
       </EditItemTemplate>
</asp:FormView>




When the wizard creates your FormView in the designer it uses
<asp:Parameters> which seem to work UNTIL I throw in an <asp:Table>
inside the FormView... Why is this?

Author
14 Oct 2006 1:37 AM
Phil H
Hi John

I don't pretend to know why the Table object causes so much grief but
if you require a table for the purposes of layout why not use a good
old fashion HTML table. I'm sure you'll find that works.

The type of table you are using is as a web server control which is
mean't to be used when you want to control its content
programmatically. If you have a fixed layout that you wish to construct
at design time then use the HTML form.