I am retrieving the Casual Leaves (CL) & Medical Leaves (ML) from a SQL Server DB table & displaying them in an HTML table using the Repeater control. It is possible that some of the records are not whole numbers; they can be something like 15.5 or 28.5 i.e. the records will either be a whole number or a fraction ending with .5 only (no other decimals allowed). I want to display the records like 30.0, 24.5, 29.0, 22.0 etc... i.e. whole numbers should be suffixed by .0 & fractional numbers should be displayed as
it is. This can be done using the InStr function to find out whether a decimal point is present in the record or not. This is what I have done:
<script language="VB" runat="server">
Sub Page_Load(obj As Object,ea As EventArgs)
Dim objDS As DataSet
Dim objConn As SQLConnection
Dim objDapter As SQLDataAdapter
objConn=New SQLConnection("Server=(local);Database=DBName;UID=sa;PWD="
objDapter=New SQLDataAdapter("SELECT EName,CL,ML FROM.......",objConn)
objDS=new DataSet()
objDapter.Fill(objDS,"LeaveDetails"
myRepeater.DataSource=objDS.Tables("LeaveDetails"
.DefaultView
myRepeater.DataBind()
End Sub
</script>
<form runat="server">
<asp:Repeater id="myRepeater" runat="server">
<HeaderTemplate>
<table border=3>
<tr>
<th>EMPLOYEE NAME</th>
<th>CASUAL LEAVES</th>
<th>MEDICAL LEAVES</th>
</tr>
</asp:HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Container.DataItem("EName"
%></td>
<td><%# Container.DataItem("CL"
%></td>
<td><%# Container.DataItem("ML"
%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
Now my question is where do I accomodate the InStr function in the above ASPX code to find out whether a number is a whole number or not - if it is a whole number, then suffix it with .0 else display the record as it is?
Thanks,
Arpan
it is. This can be done using the InStr function to find out whether a decimal point is present in the record or not. This is what I have done:
<script language="VB" runat="server">
Sub Page_Load(obj As Object,ea As EventArgs)
Dim objDS As DataSet
Dim objConn As SQLConnection
Dim objDapter As SQLDataAdapter
objConn=New SQLConnection("Server=(local);Database=DBName;UID=sa;PWD="
objDapter=New SQLDataAdapter("SELECT EName,CL,ML FROM.......",objConn)
objDS=new DataSet()
objDapter.Fill(objDS,"LeaveDetails"
myRepeater.DataSource=objDS.Tables("LeaveDetails"
myRepeater.DataBind()
End Sub
</script>
<form runat="server">
<asp:Repeater id="myRepeater" runat="server">
<HeaderTemplate>
<table border=3>
<tr>
<th>EMPLOYEE NAME</th>
<th>CASUAL LEAVES</th>
<th>MEDICAL LEAVES</th>
</tr>
</asp:HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Container.DataItem("EName"
<td><%# Container.DataItem("CL"
<td><%# Container.DataItem("ML"
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
Now my question is where do I accomodate the InStr function in the above ASPX code to find out whether a number is a whole number or not - if it is a whole number, then suffix it with .0 else display the record as it is?
Thanks,
Arpan