简体   繁体   English

如何在Gridview中编辑项目

[英]How to edit items in a Gridview

i have a gridview control and i bind some data from DB in to it.My problem is i have a price fiekd in the gridview,i bind price into it but i am getting price in this format(eg:10.0000). 我有一个gridview控件,我将DB中的一些数据绑定到它。我的问题是我在gridview中价格不高,我将价格绑定到其中,但是我以这种格式(例如:10.0000)获取价格。 How can i set it to (10.00) after binding the grid. 绑定网格后如何将其设置为(10.00)。

The gridview is gridview是

            <asp:GridView ID="gvTest" Width="600px" runat="server" onrowdeleting="gvConfigItem_RowDeleting" onrowediting="gvConfigItem_RowEditing">
               <Columns>
                  <asp:BoundField HeaderStyle-CssClass="AdminGridHeaderNew" ItemStyle-Font-Size="12px"
                        DataField="Totalprice" HeaderText="Total Price" />
             </Columns>

            </asp:GridView>

my server side code is 我的服务器端代码是

            gvTest.DataSource=ds;
            gvTest.DataBind();

You can use the DataFormatString proeprty: 您可以使用DataFormatString属性:

DataFormatString="{0:00.00}"

or 要么

DataFormatString="{0:C}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM