Display an underscore before the data in a column

  • Thread starter Thread starter Antonio
  • Start date Start date
A

Antonio

I have a datagrid which pulls from a stored procedure. For the purpose
of this display issue, we need to prepend a bound column with a
underscore "_" We don't want to change the stored procedure. can I do
this in the property builder for the datagrid?
 
this should take care of the underscore
<asp:BoundColumn DataField="fieldname"
DataFormatString="_{0}"></asp:BoundColumn>
 
You need to handle the Item_Databound Event for the datagrid. You will
be passed an EventArgs parameter that has an Item property that you can
cast to a DatagridItem object. From the DatagridItem you can reach
into its Cells property and pre-pend the "_" before the item in the
cell. You can get into the cells by doing something like this:

DataGridItem item = e.Item

item.Cells[2] <--------- represents a cell in the 3rd Column


This should give you a start.
 
Back
Top