Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Why does gridview not format boundfield columns?


Asked by Frankie Stokes on Dec 04, 2021 FAQ



BoundField columns formatting does not work when DataFormatString property is specified. Lets first see how you can specify the format string for the column. It is as simple as specifying DataFormatString property of the column.
Keeping this in consideration,
To format the data displayed in the GridView column we use DataFormatString property of BoundField. When we use a BoundField for a column, the value of a data item is displayed as text. We need to use one <BoundField> only, for each column. The <asp:BoundField> tag has three important properties.
Also Know, Format DateTime in GridView TemplateField column in ASP.Net The following HTML Markup consists of an ASP.Net GridView with two BoundField columns. The third column is a TemplateField column with a Label control and displays Birth Date in dd, MMM yyyy date format using the Eval function.
Accordingly,
Steps to create a <BoundField> column are: The first step is to declare a GridView control and set the AutoGenerateColumns property to 'false'. Next, create a <asp:BoundField> element within the <Columns> element.
In fact,
The problem is that the datatype of your data/column is a string. Your DataFormatString property will only work on a datetime column. The solution to this problem can be found in this SO answer. Because the data type of the source of that column is not datetime!