Dynamic two-way data binding

A

AM

The following block of code defines a FormView control "FormView1" with
an EditItemTemplate which has a Label and a TextBox control within it.

While the Label "RequestIDLabel1" has one-way data-binding to the
underlying column "RequestID", the TextBox "RequestDateTextBox" has
two-way data-binding to the underlying column.

If I were to generate the EditItemTemplate dynamically at runtime, and
add the Label and TextBox controls at run-time, how can I establish the
two-way data-binding between the "RequestDateTextBox" and the
"RequestDate" column?

Any help will be appreciated. Thanks.

<asp:FormView ID="FormView1" runat="server"
DataKeyNames="RequestID" DataSourceID="SqlDataSource1">
<EditItemTemplate>
RequestID:
<asp:Label ID="RequestIDLabel1" runat="server"
Text='<%# Eval("RequestID") %>'></asp:Label><br />
RequestDate:
<asp:TextBox ID="RequestDateTextBox" runat="server"
Text='<%# Bind("RequestDate") %>'>
</asp:TextBox><br />
</EditItemTemplate>
</asp:FormView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DEMO70ConnectionString %>"
SelectCommand="SELECT [RequestID], [RequestDate], [RequestDesc],
[PeopleAffected] FROM [SR]"
OldValuesParameterFormatString="original_{0}">
</asp:SqlDataSource>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top