?
Solved

Hide a separator in a datalist ASP.Net

Posted on 2010-09-22
11
Medium Priority
?
851 Views
Last Modified: 2012-06-27
With reference to: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24005751.html

Hi, can you please help more with Step 3? "After retrieving your data store off the record count and calculate IndexToClear like this"

Where do I put this in the code?

Thanks
Paul
0
Comment
Question by:auxploeb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
11 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 2000 total points
ID: 33739188
how are you populating your DataList? Using SqlDataSource or in code-behind.
Step 3 is getting data in CodeBehind. If you are doing so then it should be right after you retrieve your data.

If SDS, you can try doing in OnSelected event handler.
0
 

Author Comment

by:auxploeb
ID: 33739289
I'm using a SqlDataSource. It's still not working. Any ideas?
<asp:SqlDataSource ID="sqlGenreGeneralEntertainment" runat="server" ConnectionString="<%$ ConnectionStrings:devHousingWebSiteConnectionString %>"
                        SelectCommand="SELECT * FROM [CableChannels] where channel_genre=1" 
                        onselected="sqlGenreGeneralEntertainment_Selected" ></asp:SqlDataSource>


 <asp:DataList runat="server" ID="dlGenreGeneralEntertainment" RepeatColumns="3"
                        DataKeyField="channel_id" DataSourceID="sqlGenreGeneralEntertainment" 
                        ItemStyle-Width="165" 
                        onitemdatabound="dlGenreGeneralEntertainment_ItemDataBound" 
                        ondatabinding="dlGenreGeneralEntertainment_DataBinding">



protected void dlGenreGeneralEntertainment_ItemDataBound(object sender, DataListItemEventArgs e)
    {
       
        if (e.Item.ItemType == ListItemType.Separator)
        {
            if (e.Item.ItemIndex >= indextoclear)
            {
                e.Item.Controls.Clear();
            }
        }
    }

protected void sqlGenreGeneralEntertainment_Selected(object sender, SqlDataSourceStatusEventArgs e)
    {
        recordCount = dlGenreGeneralEntertainment.Items.Count;
        if (recordCount > 1)
        {
            indextoclear = (recordCount / 2);
        }
        else
        {
            indextoclear = -1;
        }
    }

Open in new window

0
 
LVL 41

Expert Comment

by:guru_sami
ID: 33739357
get recordcount like this:

recordCount =e.AffectedRows;
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:auxploeb
ID: 33739385
ok, got that, thanks. Now how do I adapt this for my 3 column Datalist?
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 33739432
do you have some screeshot of datalist that can explain how it's looking right now and how you want it to look. my wild guess is divide by 3 instead of 2..so try

indextoclear = (recordCount / 3);

or to be generic: indextoclear = (recordCount / DataList1.RepeatColumns);
0
 
LVL 41

Assisted Solution

by:guru_sami
guru_sami earned 2000 total points
ID: 33739610
I think it will also depend on the RepeatDirection...looks like you have Vertical which is by default...
so it should be something like this:

 indextoclear = (recordCount / 3) * 2 + 1;

and your if will be:

if (e.Item.ItemIndex > indextoclear)
            {
                e.Item.Controls.Clear();
            }

Note: I think i will give you idea to play round.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 33739804
And what was wrong...the question or the suggestions provided?
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 33771102
Though might not be exact solution, comments http:#33739188 and http:#33739610 were in right direction based on the info provided by OP.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question