1. Use dataformatstring= "{0:f}" in GridView
<asp:gridview id= "Gvpartdetail" runat= "Server" autogeneratecolumns= "False" cellpadding= "4" Font-names= "Arial" font-size= "10pt" allowpaging= "False" style= "text-align:center; Font-size:xx-small; " onrowdatabound= "Gvpartdetail_rowdatabound" > <pagersettings position= "Bottom" Visi ble= "False"/> <Columns> <asp:boundf Ield headertext= "plant_id" datafield= "plant_id"/> <asp:boundfield HeaderText = "Test Date" datafield= "test_date"/> <asp:boundfield headertext= "Yield Str" Datafield= "Yield_strength_long_front" dataformatstring= "{0:f}"/> <asp:boundfi Eld headertext= "Yield Str T6" datafield= "Yield_strength_t6" dataformatstring= "{0:f}"/> <asp:boundfield headertext= "tensile Str" datafield= "Tensile_strength_long_front" dataformatstring= "{0:F}"/> <asp:boundfield headertext= "Uniform elong%" datafield= "Uni_elongation_long_fron T "dataformatstring=" {0:f} "/> <asp:boundfield headertext=" Total Elong t6% "Da Tafield= "Te_percent_t6" dataformatstring= "{0:f}"/> </Columns> </asp:GridView>
2. Backstage through double.tostring ("F2");
Protected string Getbyviewstate_point2 (object data) { if (data! = DBNull.Value && data!=null) { var newdata = convert.todouble (data). ToString ("F2"); return newdata; } return string. Empty; }
Data displayed, 2 digits after the decimal point