Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 2nd, 2007, 10:43 AM
Registered User
Join Date: Feb 2007
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default Hiding the last Separator in a data bound DataList


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:

<asp:DataList ID="list" runat="server" CssClass="CategoryListContent" RepeatColumns="8" RepeatLayout="Flow">
      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" %>'>>
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
    <SeparatorStyle HorizontalAlign="Center" VerticalAlign="Middle" />
and code behind:

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
and class:

 // 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;
    // create a new parameter
    param = comm.CreateParameter();
    param.ParameterName = "@PrivateEntry";
    param.Value = "false";
    param.DbType = DbType.String;
    // execute the stored procedure
    return GenericDataAccess.ExecuteSelectCommand(comm);

I can post the stored procedure if required.

Any help would be greatly appreciated!
Old March 8th, 2007, 11:14 AM
Registered User
Join Date: Feb 2007
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts

Solved: I had a record with empty fields in my database.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Prefer Not To Use Data-Bound Controls... soundchaser59 ASP.NET 2.0 Basics 1 July 9th, 2007 09:13 PM
Generic Q on data bound program Minos Visual Basic 2005 Basics 1 November 9th, 2006 12:28 PM
Need help with bound data kcrompt2 Classic ASP Professional 0 February 9th, 2005 12:37 AM
Data Bound ComboBox joblot VB How-To 0 May 5th, 2004 12:18 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.