I am trying to change the data in my repeater so far I am cycling through each row by Item and AlternatingItem but I want change the values in the last column so that the value is to two decimal places. I have a basic Connection to a stored procedure which populates the repeater code below:
connection to the stored procedure:
SqlDataAdapter da = new SqlDataAdapter("Stored Procedure", conn);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add(new SqlParameter("@Admin", "ALL"));
DataSet dataset = new DataSet();
da.Fill(dataset);
rptItems.DataSource = dataset.Tables[0];
rptItems.DataBind();
Code for the ItemDataBound method:
protected void rptconsole_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==ListItemType.AlternatingItem)
{
//Code should go here which changes the values of the last column
//To two decimal places
}
}
html/XAML code to populate the repeater:
<asp:Repeater ID="rptconsole" runat="server" OnItemDataBound="rptconsole_ItemDataBound">
<HeaderTemplate>
<table id="tablework">
<th>Console</th>
<th>Color</th>
<th>Features</th>
<th>Description</th>
<th>price</th>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="center"><%# Eval("[ConsoleType]") %></td>
<td align="center"><%# Eval("[color]") %></td>
<td align="center"><%# Eval("[features]") %></td>
<td align="center"><%# Eval("[desc]") %></td>
<td align="center"><%# Eval("[price]") %></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td align="center"><%# Eval("[ConsoleType]") %></td>
<td align="center"><%# Eval("[color]") %></td>
<td align="center"><%# Eval("[features]") %></td>
<td align="center"><%# Eval("[desc]") %></td>
<td align="center"><%# Eval("[price]") %></td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>