Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 2nd, 2007, 09:43 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default Hiding the last Separator in a data bound DataList

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>
        &nbsp;|&nbsp;
    </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!
Reply With Quote
  #2 (permalink)  
Old March 8th, 2007, 10:14 AM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Default

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


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 11:28 AM
Need help with bound data kcrompt2 Classic ASP Professional 0 February 8th, 2005 11:37 PM
Data Bound ComboBox joblot VB How-To 0 May 5th, 2004 12:18 AM



All times are GMT -4. The time now is 10:58 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.