The Great Wall of Ethics – http://ethics.greynet.co.uk

So this is a strange one. I won’t say much here, but there’s more to come. For now though, you’ll find the Great Wall of Ethics here:

http://ethics.greynet.co.uk

If we’re looking to inject some maturity in to this, I did learn a bit about using ASP.NET’s basic repeater with no real modifications. Have a look:


protected void Page_Load(object sender, EventArgs e)
{
	//Sort out the ethics repeater with some data
	GetEthics ge = new GetEthics();
	List<Ethic> ethicsList = ge.List;

	EthicsRepeater.DataSource = ethicsList;
	EthicsRepeater.DataBind();

}

My Ethic object only has two real properties, EthicsName and EthicNumber. So now I’ve bound my repeater on the page to a list of Ethics, I need to actually get the data for each Ethic displayed on the page in it’s relevant ItemTemplate.


<asp:Repeater runat="server" ID="EthicsRepeater">
	<HeaderTemplate>
		<table class="Ethics">
			<tr>
				<th>Ethic #</th>
				<th>Ethic Name</th>
				<th class="center">Options</th>
			</tr>
	</HeaderTemplate>
	<ItemTemplate>
		<tr>
			<td>
				<asp:Label runat="server" Text='<%# Eval("EthicNumber") %>' />
			</td>
			<td>
				<asp:Label runat="server" Text='<%# Eval("EthicName") %>' />
			</td>
			<td class="center">
				<a class="ethic_Delete_Button" href="~/delete-ethic.aspx" data-ethicnumber='<%# Eval("EthicNumber") %>' runat="server">Delete</a>
			</td>
		</tr>
	</ItemTemplate>
	<FooterTemplate>
		</table>
		<hr />
		<a class="Button" style="float:right;" runat="server" href="~/add-ethic.aspx">Add Ethic</a>
	</FooterTemplate>
</asp:Repeater>

I’ve used this cool Eval method inside the ItemTemplate to retrieve the objects properties. I didn’t do much more digging than this as that’s all I needed, but hey ho, can’t knock it.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>