---
title: "Restrict number of decimals to be displayed from DB"  
description: "Restrict number of decimals to be displayed from DB"  
author: "Anonymous User"  
published: 2014-08-22  
updated: 2014-08-22  
canonical: https://www.mindstick.com/forum/2081/restrict-number-of-decimals-to-be-displayed-from-db  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Restrict number of decimals to be displayed from DB

I am fetching some [values](https://www.mindstick.com/forum/327/sum-textbox-values) from my DB.

The columns are of [float](https://www.mindstick.com/interview/1718/describe-float-containment) type and are being displaced in [DataList](https://www.mindstick.com/forum/1797/change-text-on-button-in-datalist-not-working) in the following manner.

```
<ItemTemplate>    <tr>    <td style="width:200px;text-align:left"> Item1: <%#Eval("Item1")%>  | 
Item2: <%#Eval("Item2") %></td>    </tr>   
</ItemTemplate>
```

I have to restrict the number of [decimal](https://www.mindstick.com/forum/34709/please-write-a-program-for-decimal-to-binary-conversion-in-c-sharp) values being displayed [int](https://www.mindstick.com/forum/159137/how-to-convert-date-int-to-date-in-sql) he [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) list to 3.

How can I do that here?

In the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii)-behind, the data is being fetched into the [DataTable](https://www.mindstick.com/blog/195/datatable-in-ado-dot-net) as follows.

```
SqlDataAdapter adp = new SqlDataAdapter("Retrieve",ConfigurationManager.ConnectionStrings["cn"].ConnectionString);             DataSet ds = new DataSet();             adp.SelectCommand.CommandType= CommandType.StoredProcedure;            
adp.SelectCommand.Parameters.Add("@s1", SqlDbType.NVarChar,255).Value = strategies;            
adp.SelectCommand.Parameters.Add("@s2", SqlDbType.NVarChar,255).Value = DropDownList1.SelectedItem.ToString();            
adp.Fill(ds);            
DataList1.DataSource = ds;            
DataList1.DataBind();
```

## Replies

### Reply by Sumit Kesarwani

HI jeet, try this:\

Eval("Item1", {0:#0.000})


---

Original Source: https://www.mindstick.com/forum/2081/restrict-number-of-decimals-to-be-displayed-from-db

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
