fm250
asked on
gridview sting format string from double
I have field bound datatype is varchar, but stored into it is double [85.321456]
I want to display it as (85.32) . and there are some null fields. thanks
I want to display it as (85.32) . and there are some null fields. thanks
ASKER
Oops, I am using C#
thanks
thanks
ASKER
Also the field is string but contain double no.
Protected void gvwRow_Databound(Object sender, GridViewRowEventArgs e)
{
If e.Row.RowType = DataControlRowType.DataRow
{
int idx = e.Row.RowIndex;
e.Row.Cells(yourcolindex). text = formatnumber(Convert.ToDou ble(e.Row. Cells(your colindex). text),2)
}
}
{
If e.Row.RowType = DataControlRowType.DataRow
{
int idx = e.Row.RowIndex;
e.Row.Cells(yourcolindex).
}
}
ASKER
here is the correct format with c# but formatnumber is not known.
if (e.Row.RowType == DataControlRowType.DataRow )
{
int idx = e.Row.RowIndex;
e.Row.Cells[5].Text = formatnumber(Convert.ToDou ble(e.Row. Cells[5].T ext),2)
}
if (e.Row.RowType == DataControlRowType.DataRow
{
int idx = e.Row.RowIndex;
e.Row.Cells[5].Text = formatnumber(Convert.ToDou
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Protected Sub gvwRow_Databound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow
Dim idx As Integer = e.Row.RowIndex
e.Row.Cells(yourcolindex).
End Sub