c# - How can I change the way my data shows up on GridView after I pulled it from SQL DB -
i pull data out of database , put in dataset through sqladapted , databind it.
my question how can change way data presented in table?
example: should have 2 digits after decimal , should have 3 etc. example: should right justified whereas should centered?
when build gridview, can assign items <asp:boundfields>
, instead of using "autogeneratecolumns". gives more control, example:
<asp:boundfield datafield="datelastcontacted" headertext="contacted" sortexpression="datelastcontacted" itemstyle-cssclass="resultscell" headerstyle-cssclass="resultsheader" itemstyle-horizontalalign="center" dataformatstring="{0:dd mmm yyy}" nulldisplaytext="n/a" />
you can use itemstyle-horizontalalign="center"
alignment, , use dataformatstring="{0:n2}"
specify decimals, see here:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx
hth
Comments
Post a Comment