hi all,
I have a Detai View I Want to Formate his cell (##,###.00) I Achive this in Grid View . But same Code Not work with DetailView
-------.aspx page code........
<asp:DetailsView ID="DetailsView3" runat="server" Height="50px" Width="125px"
CssClass="bordered" Font-Size="Smaller"
AutoGenerateRows="False" DataSourceID="SqlDataSource3" OnRowDataBound="DetailsView3_DataBound"
EnableModelValidation="True">
<Fields>
<asp:BoundField DataField="ANNL" HeaderText="ANNL" SortExpression="ANNL" ItemStyle-HorizontalAlign="Right"/>
<asp:BoundField DataField="TECH" HeaderText="TECH" SortExpression="TECH" ItemStyle-HorizontalAlign="Right"/>
<asp:BoundField DataField="COMP" HeaderText="COMP" SortExpression="COMP" ItemStyle-HorizontalAlign="Right"/>
<asp:BoundField DataField="Total" HeaderText="Total" SortExpression="Total" ItemStyle-HorizontalAlign="Right"/>
</Fields>
</asp:DetailsView>
C# -------.cs Code.....
protected void DetailsView3_DataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
e.Row.Cells[1].Text = string.Format(new CultureInfo("hi-IN", true), "{0:C}", Convert.ToInt32(e.Row.Cells[1].Text.Trim())).Substring(2);
e.Row.Cells[2].Text = string.Format(new CultureInfo("hi-IN", true), "{0:C}", Convert.ToInt32(e.Row.Cells[2].Text.Trim())).Substring(2);
e.Row.Cells[3].Text = string.Format(new CultureInfo("hi-IN", true), "{0:C}", Convert.ToInt32(e.Row.Cells[3].Text.Trim())).Substring(2);
e.Row.Cells[4].Text = string.Format(new CultureInfo("hi-IN", true), "{0:C}", Convert.ToInt32(e.Row.Cells[4].Text.Trim())).Substring(2);
}
}
Note : 1> No Error is showing. But o/p is not working.
2> Same code is running on gridview. o/p is correct.
3> This code is for Formating on cell for Show interger value like 1800 then show 1,800.00
Please Help me to achive Detail View also.