Databind problem with DetailsView's template fields

G

Guest

I am doing databinding to a DetailsView with a common business entity via the
ObjectDataSource. Everything works fine with the CRUD methods until I convert
the bound fields to template fields in order to add validation controls. Data
from the properties of the common entity just do not bind to the template
fields. Looking at the html source, I do not even see textbox controls for
displaying and entering data for edit modes; it would show only a nonbreaking
space instead. The bound fields still work correctly.

What could be the problem? Can anyone help?


..aspx source:

<asp:DetailsView ID="DetailsView1" runat="server"
AutoGenerateRows="False" DataSourceID="ObjectDataSource2"
SkinID="detailsViewSkin">
<Fields>
<asp:TemplateField HeaderText="Accounting Data"
SortExpression="AccountingData">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("AccountingData") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("AccountingData") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("AccountingData") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CmpHrsToBeChrg" HeaderText="Hours to be
Charged" SortExpression="CmpHrsToBeChrg" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="Find"
TypeName="BLL.Commands.AcctDstrEntityBLL"
DataObjectTypeName="Common.Entities.AcctDstrEntity" DeleteMethod="Delete"
UpdateMethod="Update" InsertMethod="Insert">
<SelectParameters>
<asp:SessionParameter Direction="InputOutput" Name="txnId"
SessionField="txnId" Type="String" />
<asp:ControlParameter ControlID="ListBox1"
Direction="InputOutput" Name="sequenceNbr"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>


HTML output for display mode:

<table cellspacing="0" cellpadding="2" border="0" id="ctl04_DetailsView1"
style="color:Black;background-color:LightGoldenrodYellow;border-color:Tan;border-width:1px;border-style:solid;border-collapse:collapse;">
<tr>

<td>Accounting Data</td><td> </td>
</tr><tr style="background-color:paleGoldenrod;">
<td>Hours to be Charged</td><td>13 00</td>
</tr><tr>
<td colspan="2"><a
href="javascript:__doPostBack('ctl04$DetailsView1','Edit$0')"
style="color:Black;">Edit</a> <a
href="javascript:__doPostBack('ctl04$DetailsView1','Delete$0')"
style="color:Black;">Delete</a> <a
href="javascript:__doPostBack('ctl04$DetailsView1','New$0')"
style="color:Black;">New</a></td>
</tr>

</table>


HTML output for edit mode:

<table cellspacing="0" cellpadding="2" border="0" id="ctl04_DetailsView1"
style="color:Black;background-color:LightGoldenrodYellow;border-color:Tan;border-width:1px;border-style:solid;border-collapse:collapse;">
<tr style="color:GhostWhite;background-color:DarkSlateBlue;">

<td>Accounting Data</td><td> </td>
</tr><tr style="color:GhostWhite;background-color:DarkSlateBlue;">
<td>Hours to be Charged</td><td><input name="ctl04$DetailsView1$ctl01"
type="text" value="13 00" title="Hours to be Charged" /></td>
</tr><tr>
<td colspan="2"><a
href="javascript:__doPostBack('ctl04$DetailsView1$ctl02','')"
style="color:Black;">Update</a> <a
href="javascript:__doPostBack('ctl04$DetailsView1','Cancel$0')"
style="color:Black;">Cancel</a></td>
</tr>
</table>
 

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,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top