data formatted as a currency, then you must have another problem. We can't
get to my question until you can get that far. I didn't do anything special
take that bound column and format it as a currency. That part works like a
"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
news:zUXipNCLIHA.7800@TK2MSFTNGHUB02.phx.gbl...
> Hi Scott,
>
> Here is the aspx template of my test page
>
> price column is the one of smallmoney type in SQL Express:
>
> =======================
> <form id="form1" runat="server">
> <div>
> <asp:SqlDataSource ID="SqlDataSource1" runat="server"
> ConnectionString="<%$ ConnectionStrings:testdbConnectionString %>"
> DeleteCommand="DELETE FROM [sm_tb] WHERE [id] = @id"
> InsertCommand="INSERT INTO [sm_tb] ([name], [price]) VALUES (@name,
> @price)"
> SelectCommand="SELECT [id], [name], [price] FROM [sm_tb]"
> UpdateCommand="UPDATE [sm_tb] SET [name] = @name, [price] = @price WHERE
> [id] = @id">
> <DeleteParameters>
> <asp:Parameter Name="id" Type="Int64" />
> </DeleteParameters>
> <UpdateParameters>
> <asp:Parameter Name="name" Type="String" />
> <asp:Parameter Name="price" Type="Decimal" />
> <asp:Parameter Name="id" Type="Int64" />
> </UpdateParameters>
> <InsertParameters>
> <asp:Parameter Name="name" Type="String" />
> <asp:Parameter Name="price" Type="Decimal" />
> </InsertParameters>
> </asp:SqlDataSource>
> <asp:GridView ID="GridView1" runat="server"
> AutoGenerateColumns="False" DataKeyNames="id"
> DataSourceID="SqlDataSource1">
> <Columns>
> <asp:CommandField ShowDeleteButton="True"
> ShowEditButton="True" />
> <asp:BoundField DataField="id" HeaderText="id"
> InsertVisible="False" ReadOnly="True"
> SortExpression="id" />
> <asp:BoundField DataField="name" HeaderText="name"
> SortExpression="name" />
> <asp:BoundField DataField="price" HeaderText="price"
> SortExpression="price" DataFormatString="{0:c}" />
> </Columns>
> </asp:GridView>
>
> </div>
> </form>
> ===========================
>
> Anything I should changed to match your case?
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
>
>
>
>
>
>
>
>
> --------------------
>>Reply-To: "Scott M." <smar@nospam.nospam>
>>From: "Scott M." <smar@nospam.nospam>
>>Subject: Re: {0:c} causes input string not in correct format exception
>>Date: Tue, 20 Nov 2007 00:22:04 -0500
>
>>
>>Is this what you want Steven:
>>
>> <asp:BoundField DataField="RetailPrice"
>>HeaderText="RetailPrice" SortExpression="RetailPrice"
>> DataFormatString="{0:c}" />
>>
>>This does cause my displayed amounts to be formatted as currency, which is
> a
>>"catch 22" since now when I try to delete, the value in the bound field is
>>not the same as it was when it was loaded into the gridview. Now, the
> value
>>in this column is no longer compatible with a decimal, double or
> smallmoney
>>and so the delete attempt fails.
>>
>>You mention that you are not seeing your smallmoney SQL amount formatted
> as
>>a currency amount, which you should be, so I think you don't have your
> test
>>set up correctly.
>>
>>-Scott
>>
>>
>>"Steven Cheng[MSFT]" <stcheng@online.microsoft.com> wrote in message
>>news:%23ZQDxBzKIHA.5204@TK2MSFTNGHUB02.phx.gbl...
>>> Hi Scott,
>>>
>>> From your description, you're encountering some "input string incorrect
>>> format ..." error when deleting record in GridView(with DataFormatString
>>> set in column), right?
>>>
>>> According to the setting you mentioned, I've performed a simple test
>>> with
>>> the following things:
>>>
>>>
>>> * use a simple SQL Express table with a column(of "smallmoney" type)
>>> * in ASPX page, you SqlDataSource to connect that table(enable edit,
>>> delete)
>>> * in GridView, enable Edit,Delete and also apply the following
>>> formatstring
>>> to the boundField(of that smallmoney column)
>>>
>>> "{0:c}"
>>>
>>>
>>> ============
>>> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
>>> DataKeyNames="id" DataSourceID="SqlDataSource1">
>>> <Columns>
>>> <asp:CommandField ShowDeleteButton="True"
>>> ShowEditButton="True" />
>>> <asp:BoundField DataField="id" HeaderText="id"
>>> InsertVisible="False" ReadOnly="True"
>>> SortExpression="id" />
>>> <asp:BoundField DataField="name" HeaderText="name" SortExpression="name"
>>> />
>>> <asp:BoundField DataField="price" HeaderText="price"
>>> SortExpression="price" DataFormatString="{0:c}" />
>>> </Columns>
>>> </asp:GridView>
>>> =================
>>>
>>> However, the currency symbol doesn't display by default and I can get
>>> the
>>> record updated or deleted correctly. Therefore, I think there should be
>>> something different from mine in your page. Would you give me a aspx
>>> template so that I can test against it?
>>>
>>> Sincerely,
>>>
>>> Steven Cheng
>>>
>>> Microsoft MSDN Online Support Lead
>>>
>>>
>>>
>>> ==================================================
>>>
>>> Get notification to my posts through email? Please refer to
>>>
>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif >>> ications.
>>>
>>>
>>>
>>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
> issues
>>> where an initial response from the community or a Microsoft Support
>>> Engineer within 1 business day is acceptable. Please note that each
> follow
>>> up response may take approximately 2 business days as the support
>>> professional working with you may need further investigation to reach
>>> the
>>> most efficient resolution. The offering is not appropriate for
>>> situations
>>> that require urgent, real-time or phone-based interactions or complex
>>> project analysis and dump analysis issues. Issues of this nature are
>>> best
>>> handled working with a dedicated Microsoft Support Engineer by
>>> contacting
>>> Microsoft Customer Support Services (CSS) at
>>>
http://msdn.microsoft.com/subscriptions/support/default.aspx. >>>
>>> ==================================================
>>>
>>>
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>>
>>>
>>>
>>> --------------------