Link to home
Start Free TrialLog in
Avatar of auxploeb
auxploeb

asked on

Hide a separator in a datalist ASP.Net

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
ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of auxploeb
auxploeb

ASKER

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

get recordcount like this:

recordCount =e.AffectedRows;
ok, got that, thanks. Now how do I adapt this for my 3 column Datalist?
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);
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And what was wrong...the question or the suggestions provided?
Though might not be exact solution, comments http:#33739188 and http:#33739610 were in right direction based on the info provided by OP.