Steven,
I am using the Bind expression.
So, are you saying that there is no simple way to retain the entered values
of the controls if the insert fails?
That I must 'find' all the controls and repopulate them myself?
Here is the insert template
<InsertItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td style="width: 15%" valign="top">
Record #</td>
<td style="width: 1%" valign="top">
:</td>
<td style="width: 84%" valign="top">
</td>
</tr>
<tr>
<td style="width: 15%" valign="top">
Entry Date</td>
<td style="width: 1%" valign="top">
:</td>
<td style="width: 84%" valign="top">
<asp:TextBox ID="EntryDateTextBox" runat="server" Text='<%#
Bind("EntryDate") %>' Width="100px"></asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 15%" valign="top">
Life Areas</td>
<td style="width: 1%" valign="top">
:</td>
<td style="width: 84%" valign="top">
<asp:CheckBoxList ID="LifeAreasCheckBoxList" runat="server"
DataSourceID="odsLifeArea"
DataTextField="LifeAreaDesc" DataValueField="LifeAreaId" RepeatColumns="3">
</asp:CheckBoxList></td>
</tr>
<tr>
<td style="width: 15%" valign="top">
Service</td>
<td style="width: 1%" valign="top">
:</td>
<td style="width: 84%" valign="top">
<asp:DropDownList ID="ServicesDropDownList" runat="server"
DataSourceID="odsServices"
DataTextField="Service" DataValueField="ServiceID" SelectedValue='<%#
Bind("ServiceId") %>' AutoPostBack="True"
OnSelectedIndexChanged="ServicesDropDownList_Selec tedIndexChanged">
</asp:DropDownList></td>
</tr>
<tr>
<td style="width: 15%" valign="top">
Service Type</td>
<td style="width: 1%" valign="top">
:</td>
<td style="width: 84%" valign="top">
<asp:DropDownList ID="ddlServiceTypeID" runat="server"
DataSourceID="odsCPN_ServiceType"
DataTextField="ServiceType" DataValueField="ServiceTypeId"
SelectedValue='<%# Bind("ServiceTypeId") %>'>
</asp:DropDownList>
<asp:TextBox ID="txtOtherServiceType" runat="server" Text='<%#
Bind("OtherServiceType") %>' MaxLength="50"
Width="175px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 15%" valign="top">
Time Spent</td>
<td style="width: 1%" valign="top">
:</td>
<td style="width: 84%" valign="top">
<asp:TextBox ID="txtTimeSpent" runat="server" Text='<%# Bind("TimeSpent")
%>' Width="80px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 15%; height: 16px" valign="top">
Format</td>
<td style="width: 1%; height: 16px" valign="top">
:</td>
<td style="width: 84%; height: 16px" valign="top">
<asp:DropDownList ID="FormatDropDownList" runat="server" SelectedValue='<%#
Bind("FormatID") %>' AutoPostBack="True"
OnDataBound="FormatDropDownList_DataBound"
OnSelectedIndexChanged="FormatDropDownList_Selecte dIndexChanged"
DataSourceID="odsCPN_Format" DataTextField="FormatName"
DataValueField="FormatID">
</asp:DropDownList></td>
</tr>
</table>
<hr />
<asp:GridView ID="gvFormatPartNotes" Width="100%" runat="server"
AutoGenerateColumns="false" DataKeyNames="FormatPartLabel"
BorderColor="Transparent" ShowHeader="false" BorderWidth="0px"
OnRowDataBound ="gvFormatPartNotes_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="Label">
<ItemTemplate>
<asp:Label ID="lblFormatPartLabel" runat="server" Text='<%#
Bind("FormatPartLabel") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="15%" />
<HeaderStyle Width="15%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Notes">
<ItemTemplate>
<asp:TextBox ID="txtFormatPartNotes" runat="server" Text='<%# Bind("Notes")
%>' TextMode="MultiLine" Rows="4" Width="95%"></asp:TextBox>
<asp:RequiredFieldValidator ID="valrFormatPartNotes" runat="server"
ControlToValidate="txtFormatPartNotes"
Display="Dynamic" EnableViewState="False" ErrorMessage="Required"
SetFocusOnError="True"></asp:RequiredFieldValidator>
</ItemTemplate>
<ItemStyle Width="85%" />
<HeaderStyle Width="85%" />
</asp:TemplateField>
</Columns>
</asp:GridView>
<hr />
<asp:Label ID="ClientIdLabel" runat="server" Text='<%# Bind("MemberID") %>'
Visible="False"></asp:Label><br />
<asp:Label ID="EpisodeNumberLabel" runat="server" Text='<%#
Bind("EpisodeNumber") %>' Visible="False"></asp:Label>
<asp:Label ID="AgencyNumberLabel" runat="server" Text='<%#
Bind("AgencyNumber") %>' Visible="False"></asp:Label>
<asp:Label ID="TPIdLabel" runat="server" Text='<%# Bind("TPId") %>'
Visible="False"></asp:Label><br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert"
Text="Insert" OnClick="InsertButton_Click">
</asp:LinkButton>
</InsertItemTemplate>
--
AG
Email: discuss at adhdata dot com
"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:P1**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply AG,
Sure, if possible, I would prefer using the two-way databing( through the
"Bind" expression I mentioned previously). However, the Bind experssion
normally attached to a top level property of a certain control in the
FormView(or other template databound control's template).
Anyway, using the ItemUpdating or ItemInserting event and manually locate
Control (through FindControl) approach will certainly work. For yoru
scenario, I'm still wondering your FormView's InsertTemplate control
structure and your objectdatasource insert method's signature and how it
is
defined in aspx template. Would you provide me some code snippet so that I
can get a further view about it?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.