Hi,
I have a DataList data bound in the code behind using a custom class. Does anyone know if you can hide the last separator after the last data item?
My generated list looks like:
Far Away | Flora | Landscapes | Seaside | Villages | Quirky | Urban |
I want to hide the separator marked in red.
Heres my code:
Code:
<asp:DataList ID="list" runat="server" CssClass="CategoryListContent" RepeatColumns="8" RepeatLayout="Flow">
<ItemTemplate>
<asp:HyperLink
ID="HyperLink1"
Runat="server"
NavigateUrl='<%# "../Catalog.aspx?DepartmentID=" + Request.QueryString["DepartmentID"] + "&CategoryID=" + Eval("CategoryID") %>'
Text='<%# Eval("Name") %>'
ToolTip='<%# Eval("Description") %>'
CssClass='<%# Eval("CategoryID").ToString() == Request.QueryString["CategoryID"] ? "CategorySelected" : "CategoryUnselected" %>'>>
</asp:HyperLink>
</ItemTemplate>
<SeparatorTemplate>
|
</SeparatorTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<SeparatorStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:DataList>
and code behind:
Code:
public partial class CategoriesList : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
// don't reload data during postbacks
if (!IsPostBack)
{
// Obtain the ID of the selected department
string departmentId = Request.QueryString["DepartmentID"];
// Continue only if DepartmentID exists in the query string
if (departmentId != null)
{
// Catalog.GetCategoriesInDepartment returns a DataTable object containing
// category data, which is displayed by the DataList
list.DataSource = CatalogAccess.GetCategoriesInDepartment(departmentId);
// Needed to bind the data bound controls to the data source
list.DataBind();
}
}
}
}
and class:
Code:
// retrieve the list of categories in a department
public static DataTable GetCategoriesInDepartment(string departmentId)
{
// get a configured DbCommand object
DbCommand comm = GenericDataAccess.CreateCommand();
// set the stored procedure name
comm.CommandText = "GetCategoriesInDepartment";
// create a new parameter
DbParameter param = comm.CreateParameter();
param.ParameterName = "@DepartmentID";
param.Value = departmentId;
param.DbType = DbType.Int32;
comm.Parameters.Add(param);
// create a new parameter
param = comm.CreateParameter();
param.ParameterName = "@PrivateEntry";
param.Value = "false";
param.DbType = DbType.String;
comm.Parameters.Add(param);
// execute the stored procedure
return GenericDataAccess.ExecuteSelectCommand(comm);
}
I can post the stored procedure if required.
Any help would be greatly appreciated!