k its fine but the data is coming through database its not a bound fiels or custom field
I suppose, u have set autogeneratecolumns to true for gridview... so u dont have columns defined using boundcolumn or templatecolumn...
u can create RowDataBound event of gridview (select gridview and go to properties window... navigate to event section and doubleclick on RowDataBound event)
suribabuk
Member
2 Points
42 Posts
Thousand Seperator in Grid view
Apr 13, 2012 10:06 AM|LINK
how to get Thousand seperator in Gridview columns when the column is a number either any type
mm10
Contributor
6395 Points
1182 Posts
Re: Thousand Seperator in Grid view
Apr 13, 2012 10:16 AM|LINK
<asp:BoundField DataField="YourFieldId" HeaderText="..." DataFormatString="{0:0,0.0}" />
kedarrkulkar...
All-Star
34013 Points
5468 Posts
Re: Thousand Seperator in Grid view
Apr 13, 2012 10:16 AM|LINK
if it is boundfield... then try using dataformatstring
<asp:boundfield datafield="ColumnName" dataformatstring="{0:N}" />
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
suribabuk
Member
2 Points
42 Posts
Re: Thousand Seperator in Grid view
Apr 13, 2012 10:27 AM|LINK
k its fine but the data is coming through database its not a bound fiels or custom field
Huske
Contributor
4060 Points
756 Posts
Re: Thousand Seperator in Grid view
Apr 13, 2012 10:28 AM|LINK
You would normally use something like {0:#.##} when formatting data.
suribabuk
Member
2 Points
42 Posts
Re: Thousand Seperator in Grid view
Apr 13, 2012 10:37 AM|LINK
which place did i use this after databind() method
kedarrkulkar...
All-Star
34013 Points
5468 Posts
Re: Thousand Seperator in Grid view
Apr 13, 2012 10:46 AM|LINK
I suppose, u have set autogeneratecolumns to true for gridview... so u dont have columns defined using boundcolumn or templatecolumn...
u can create RowDataBound event of gridview (select gridview and go to properties window... navigate to event section and doubleclick on RowDataBound event)
define event as this
protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[1].Text = Strings.Format(Convert.ToDecimal(e.Row.Cells[1].Text), "#,##0.00"); } }considering second column (index 1) need to be formatted i have used Cells[1] in above code... replace index value based on column sequence number
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
suribabuk
Member
2 Points
42 Posts
Re: Thousand Seperator in Grid view
Apr 13, 2012 10:59 AM|LINK
thank u very much but i am using devexpress gridview its not have a rowdatabound event its only have databound event is it similar or different
kedarrkulkar...
All-Star
34013 Points
5468 Posts
Re: Thousand Seperator in Grid view
Apr 13, 2012 11:14 AM|LINK
is it ASPxGridView? i think u can use HtmlDataCellPrepared event then
check the HtmlDataCellPrepared event in this link
http://www.devexpress.com/Support/Center/e/E84.aspx
the syntax for formatting the value should remain same
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
suribabuk
Member
2 Points
42 Posts
Re: Thousand Seperator in Grid view
Apr 13, 2012 11:26 AM|LINK
Thank u very much i will check it