About itemdatabound

Posted on 2004-11-02
Last Modified: 2012-06-27
i have this repeater in my page

<asp:repeater id="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
    <table width="100%" class="table">
    <td width="10%" bgcolor="Beige">
    <asp:Label id="lbhora" Runat="server">
    <%# Convert.ToDateTime(DataBinder.Eval(Container.DataItem, "StartTime")).ToShortTimeString() %>
    <td bgcolor="LemonChiffon">
    <asp:LinkButton id="Linkbutton3" runat="Server" CssClass="aa" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"Href") %>' CommandName="Select">
    <%# DataBinder.Eval(Container.DataItem, "Task") %>

as you could see im trying to build a daily schedule. this is working fine.
But. i want to have two events in the same time, together. as this:

10:30  event 1 - event 2 - event 3 (or something like that!)

how can i save the last time binded?
any ideas?

ask me if it is not explained enough!
Question by:FLUXWIRE
    LVL 9

    Expert Comment

    Well, hi Fluxwire.

    You have to create a new repeater inside your main repeater (nestead repeater).
    Then, you can add all events you want inside nestead repeater.

    Hope this help you.

    Author Comment

    The solution is very nice!
    I dont know yet how to implement it.

    I have a datatable that i use as datasource for my repeater.
    this datatable has two columns. the time and the event.
    i will put the second repeater in the table cell where i have the events.
    this second repeater i will need to bind with a datatable view where i
    select events from the same time?

    LVL 9

    Expert Comment

    You have to rebuild your dataset schema:
    datatableTime (scheduleTimeId,datetime,...)

    Then you set the datasource of your master repeater to datatableTime and for the nestead repeater, you set the datasource in itemdatabound event depends on which item is selected, so which time is selected.

    Hope you see how to proceed.

    Author Comment

    I got some examples using two tables with relationship between them.
    But in this case i have only one table. like this
    12:00 event1
    12:30 event2
    12:30 event3
    12:30 event4
    15:00 event5
    and so on.
    how can i use only this table to put the time in the first repeater and the event name in the second?

    sorry. i didnt get it yet!
    LVL 9

    Accepted Solution

    you have to create two temporary tables:
    the first one will contains the datetime and the second one all events with the relationship like in my previous post.
    datatableTime (scheduleTimeId,datetime,...)

    DataTable datatableTime=new DataTable();
    DataColumn dataColumnscheduleTimeId=new DataColumn();
    datatableTime.Columns.Add(dataColumnscheduleTimeId); ...

    DataTable datatableTimeEvents=new DataTable();
    DataColumn dataColumnEventId=new DataColumn();
    DataColumn dataColumnscheduleTimeId=new DataColumn();
    datatableTimeEvents.Columns.Add(dataColumnscheduleTimeId); ...

    DataSet dataSetTemp=new DataSet();
    dataSetTemp.Relations.Add(new Relation()); ... (with VS it's easier to define the relation between those tables)

    Now, you have your temporary dataset and tables.
    This is a summary of how you can proceed.

    Then you set the datasource of your master repeater to datatableTime and for the nestead repeater, you set the datasource in itemdatabound event depends on which item is selected, so which time is selected.

    Author Comment

    ok. i get it!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Article by: Ivo
    C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now