GetDecimal

S

Sam

<asp:DataGrid id="myDataGrid" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="gbaid" HeaderText="Account
ID" />
<asp:BoundColumn DataField="account_num"
HeaderText="account_num" />
<asp:BoundColumn DataField="acc_desc"
HeaderText="Description" />
<asp:BoundColumn DataField="amount" HeaderText="Amount"
/>
</Columns>
</asp:DataGrid>

How do I perform amount in 2 decimal places?

Please help.
 
S

Sam

Thanks but it encounter error. What should I change in my coding?

Format specifier was invalid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.FormatException: Format specifier was invalid.

Source Error:
Line 58:
Line 59: myDataGrid.DataSource = okrd
Line 60: myDataGrid.DataBind()
Line 61:
Line 62: okrd.Close()

Coding
-------
Dim okcon As New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim okcmd As New SqlCommand()


okcmd.CommandText = "Select gbaid,account_num,acc_desc,amount from f0902
where gbmcu = " & _
TextBox_Account.Text & " and gblt =
'" & DropDownlist_LedgerType.SelectedItem.Value & _
"' order by account_num"

okcmd.Connection = okcon

Try
okcon.Open()

Dim okrd As SqlDataReader = okcmd.ExecuteReader()

myDataGrid.DataSource = okrd
myDataGrid.DataBind()

okrd.Close()

Finally
okcon.Close()
End Try
 
M

Matt Berther

Hello Sam,

You might try {0:F2} instead. The documentation that I linked to may be incorrect.
 

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

Top