N
Next
Hello,
I trying to convert an ASP page to ASP.NET using a DataGrid control.
All of the data is being displayed in the DataGrid. But I need help with
formatting.
The asp code segment looks like this:
<%
' list out the metals
do while not rsMetals.eof
intChange = rsMetals(2) - rsMetals(1)
if intChange > 0 or intChange = 0 then
intChange = FormatNumber(intChange, rsMetals(4),,True)
Response.Write "<TR><TD>" & rsMetals(0) & "</TD>" & _
"<TD></TD>" & _
"<TD></TD>" & _
"<TD>$" & FormatNumber(rsMetals(2), rsMetals(4)) & "</TD>" & _
"<TD>$" & intChange & "</TD>" & _
"<TD>" & rsMetals(3) & "</TD></TR>"
else
intChange = FormatNumber(intChange, rsMetals(4),,True)
Response.Write "<TR><TD>" & rsMetals(0) & "</TD>" & _
"<TD></TD>" & _
"<TD></TD>" & _
"<TD>$" & FormatNumber(rsMetals(2), rsMetals(4)) & "</TD>" & _
'-----Decimal places
"<TD><FONT COLOR='#ff0000'>$" & intChange & "</FONT></TD>" & _
'-----Red if < 0
"<TD>" & rsMetals(3) & "</TD></TR>"
end if
rsMetals.MoveNext
loop
rsMetals.close
%>
My DataGrid looks like this:
<aspataGrid id="grdPMetals" runat="server" AutoGenerateColumns="False"
Width="100%" CssClass="Content">
<Columns>
<asp:BoundColumn HeaderText="SPOT" DataField="descr"
ItemStyle-Width="34%" />
<asp:BoundColumn HeaderText="Current" DataField="spot"
ItemStyle-Width="13%" />
<asp:BoundColumn HeaderText="Change From<br>Previous Close*"
DataField="change" ItemStyle-Width="19%" />
<asp:BoundColumn HeaderText="Last Update"
DataField="last_mod_date" ItemStyle-Width="34%" />
</Columns>
</aspataGrid>
1) If intChange is less than zero, I want to change the color to Red and
show in parenthises instead of a negative sign?
2) My second problem is is formatting the number of decimal places. The
above code uses the function "FormatNumber(intChange, rsMetals(4),,True)"
where rsMetals is the number of decimal places to display.
Any help would be greatly appreciated! Thanks in advance for your time.
Aaron
I trying to convert an ASP page to ASP.NET using a DataGrid control.
All of the data is being displayed in the DataGrid. But I need help with
formatting.
The asp code segment looks like this:
<%
' list out the metals
do while not rsMetals.eof
intChange = rsMetals(2) - rsMetals(1)
if intChange > 0 or intChange = 0 then
intChange = FormatNumber(intChange, rsMetals(4),,True)
Response.Write "<TR><TD>" & rsMetals(0) & "</TD>" & _
"<TD></TD>" & _
"<TD></TD>" & _
"<TD>$" & FormatNumber(rsMetals(2), rsMetals(4)) & "</TD>" & _
"<TD>$" & intChange & "</TD>" & _
"<TD>" & rsMetals(3) & "</TD></TR>"
else
intChange = FormatNumber(intChange, rsMetals(4),,True)
Response.Write "<TR><TD>" & rsMetals(0) & "</TD>" & _
"<TD></TD>" & _
"<TD></TD>" & _
"<TD>$" & FormatNumber(rsMetals(2), rsMetals(4)) & "</TD>" & _
'-----Decimal places
"<TD><FONT COLOR='#ff0000'>$" & intChange & "</FONT></TD>" & _
'-----Red if < 0
"<TD>" & rsMetals(3) & "</TD></TR>"
end if
rsMetals.MoveNext
loop
rsMetals.close
%>
My DataGrid looks like this:
<aspataGrid id="grdPMetals" runat="server" AutoGenerateColumns="False"
Width="100%" CssClass="Content">
<Columns>
<asp:BoundColumn HeaderText="SPOT" DataField="descr"
ItemStyle-Width="34%" />
<asp:BoundColumn HeaderText="Current" DataField="spot"
ItemStyle-Width="13%" />
<asp:BoundColumn HeaderText="Change From<br>Previous Close*"
DataField="change" ItemStyle-Width="19%" />
<asp:BoundColumn HeaderText="Last Update"
DataField="last_mod_date" ItemStyle-Width="34%" />
</Columns>
</aspataGrid>
1) If intChange is less than zero, I want to change the color to Red and
show in parenthises instead of a negative sign?
2) My second problem is is formatting the number of decimal places. The
above code uses the function "FormatNumber(intChange, rsMetals(4),,True)"
where rsMetals is the number of decimal places to display.
Any help would be greatly appreciated! Thanks in advance for your time.
Aaron