W
WJB
Hi,
I have a TextBox in a FormView ItemTemplate that uses a function to perform
special formatting on the retrieved field content that is bound to the
control as in the following control (the GetFormattedField function is in my
code behind .cs file):
<asp:TextBox ID="txtPhoneNumber" runat="server" Text='<%#
GetFormattedField(Eval("dbField"), "txtField") %>'
Style="z-index: 122; left: 442px; position: absolute; top: 76px"
Width="100px" ReadOnly="True" ></asp:TextBox>
I'm also using an ObjectDataSource as the data source for the FormView, and
have ConflictDetection for the source set to CompareAllValues. For this to
work, I've had to change all my Eval("xxx") bindings to Bind("xxx") within
the ItemTemplate, while adding ReadOnly="True" to all the FormView controls.
I found this to be the only way that the ObjectDataSource will fill the
e.Values array so that these values can be passed in to the DeleteMethod of
the DAL class by the ObjectDataSource, which is done in the ItemDeleting
event of the FormView. Hence my problem:
The e.Values array will only be filled if the ItemTemplate uses Bind rathern
than Eval for evey control within it. However, only Eval is allowed within my
GetFormattedField function. I'm thinking that a way out might be to trap the
Delete button click and in that event replace the "<%#
GetFormattedField(Eval("dbFIeld"), "txtField") %>" string with a "<%#
Bind("dbFIeld") %>" string. However, I cannot get to that Text property to
change it.
1. Does my approach make sense?
2. If so, how do I access this property so I can changed it?
3. If not, how can I otherwise accomplish what I need to do, and that is,
retain the call to the field formatting function when retrieving the row from
the database to display in the FormView, and at the same time, preserve the
Bind call so that the CompareAllValues Delete can operate correctly by
filling up the entire e.Values array?
Thanks
I have a TextBox in a FormView ItemTemplate that uses a function to perform
special formatting on the retrieved field content that is bound to the
control as in the following control (the GetFormattedField function is in my
code behind .cs file):
<asp:TextBox ID="txtPhoneNumber" runat="server" Text='<%#
GetFormattedField(Eval("dbField"), "txtField") %>'
Style="z-index: 122; left: 442px; position: absolute; top: 76px"
Width="100px" ReadOnly="True" ></asp:TextBox>
I'm also using an ObjectDataSource as the data source for the FormView, and
have ConflictDetection for the source set to CompareAllValues. For this to
work, I've had to change all my Eval("xxx") bindings to Bind("xxx") within
the ItemTemplate, while adding ReadOnly="True" to all the FormView controls.
I found this to be the only way that the ObjectDataSource will fill the
e.Values array so that these values can be passed in to the DeleteMethod of
the DAL class by the ObjectDataSource, which is done in the ItemDeleting
event of the FormView. Hence my problem:
The e.Values array will only be filled if the ItemTemplate uses Bind rathern
than Eval for evey control within it. However, only Eval is allowed within my
GetFormattedField function. I'm thinking that a way out might be to trap the
Delete button click and in that event replace the "<%#
GetFormattedField(Eval("dbFIeld"), "txtField") %>" string with a "<%#
Bind("dbFIeld") %>" string. However, I cannot get to that Text property to
change it.
1. Does my approach make sense?
2. If so, how do I access this property so I can changed it?
3. If not, how can I otherwise accomplish what I need to do, and that is,
retain the call to the field formatting function when retrieving the row from
the database to display in the FormView, and at the same time, preserve the
Bind call so that the CompareAllValues Delete can operate correctly by
filling up the entire e.Values array?
Thanks