我正在使用aspx页面中的Gridview。 更具体地说,在gridview中,我正在处理一个名为Price
的特定列。gridview中的Price列值示例应如下所示:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/appBar"/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/appBar"
android:clickable="true">
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v4.view.PagerTabStrip
android:id="@+id/pager_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="30dp"
android:paddingBottom="4dp"
android:paddingTop="4dp"
/>
</android.support.v4.view.ViewPager>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
为了获得此结果,这是我在aspx文件中尝试过的操作:
Price
1.50 AUD
10.00 AUD
15.55 AUD
100.50 AUD
当我将鼠标光标放在DataFormatString语法上时,这是显示的错误消息:
<asp:TemplateField HeaderText="Price" DataFormatString="{0} AUD" >
<ItemTemplate>
<asp:TextBox ID ="TextBox1" runat="server" DataField="Product_Price" Text='<%#Eval("Price")%>' />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Numbers with decimals only" ControlToValidate="TextBox1" ValidationExpression="^[0-9]+(\.[0-9][0-9]?)?"></asp:RegularExpressionValidator>
<asp:Button ID ="Button1" runat="server" OnClick="Update_Click" CommandArgument="Button7" CommandName="Update" Text="Update" />
</ItemTemplate>
</asp:TemplateField>
我在哪里弄错了?
如果提供适当的解决方案语法,将很有帮助。
答案 0 :(得分:1)
尝试
<asp:TextBox ID ="TextBox1" runat="server" DataField="Product_Price" Text='<%#Eval("Price","{0:c}")%>' />