Is there an available web control like this?

Discussion in 'ASP .Net Web Controls' started by Erick T, Aug 7, 2003.

  1. Erick T

    Erick T Guest

    Hello,

    I am looking for a Web UI Control, either commercial or free. I don't
    know exactly what to call it, so I will describe what I need it to do.
    In a nutshell, it's a control to visually represent an intersection
    table in a many-to-many relationship. For example, in this ERD

    Country ----< CountryVisit >---- Person

    each country can have more then one person visiting, and each person
    can visit more then one country. What I want to have is a way to
    display/edit information for the association/intersection table; all
    possible records shown with one end fixed (either all Countries for a
    person, or vise versa). The CountryVisit (or intersection) table could
    have a number of fields

    CountryID
    PersonID
    DateOfVisit
    etc

    So the control needs to behave like the DataGrid, where you can define
    a template for the items to be displayed. So if my countries were
    (USA, Canada, UK) I could fix the Person, and the control would show
    (for example) (aircode, but if anything doesn't make sense, let me
    know)

    <ItemTemplate>
    <asp:checkbox checked=<%
    IsNull(Container.DataItem("Item.CountryID")) %> Text=<%
    Container.DataItem("Item.CountryName") %> />
    </ItemTemplate>

    and the ItemTemplate would repeat for all possible Countries. Also,
    the control would have events for when a row in the intersection table
    is created or deleted, so I could set the columns as needed.

    The reason I want this control is that a lot of my databases have
    large numbers of these intersections tables. And I seem to end up
    writing the same code over and over again. What I generally write is
    below.

    I need a method in my code behind to correctly populate the List,
    which is called when the elements of the page are DataBound. e.g.,

    <asp:CheckBoxList id="checkBoxList" DataSource = "Country" etc />

    and in the codebehind:

    CountryVisitView.Filter = "PersonID = " + someID;
    foreach (CountryVisitRow r in CountryVisitView) {
    list.FindItem(r.CountryID).Checked = true;
    // set other properties (date, etc)
    }

    Then, in my update method, I often end up doing something like this,
    which simply syncs the contents of the list to the recordset.

    CountryVisitView.Filter = "PersonID = " + someID;
    // find newly added rows in intersection
    foreach (Item i in checkBoxList) {
    if (i.Checked == true) {
    // or method which loops over the view
    if (!CountryVisitView.Contains(i.CountryID)) {
    // add row to CountryVisitView
    }
    }
    if (i.Checked == false) {
    if (!CountryVisitView.Contains(i.CountryID)) {
    // remove row from country view
    }
    }
    }

    What I would like, is something like

    <IdealControl
    IntersectDataSource="CountryVisit"
    Relationship1Name="CountryVisitCountry">
    Relationship2Name="CountryVisitPerson"
    Fixed="PersonID=123"
    OnAdd="AddIntersectRec"
    OnRemove="RemoveIntersectRec"
    >

    <ItemTemplate>
    <asp:CheckBox ... > etc
    // with DataItem a reference to the current
    DataRow/DataRowView of the intersection table
    </ItemTemplate>
    </IdealControl>

    Then, the OnAdd/OnRemove events would work like the ADO.NET
    SqlRowUpdating event, where I can inspect/update/cancel the pending
    operation (the addition or removal of the row in the Intersection
    table). I hope this makes sense, if not, let me know and I'll answer
    anything I can.

    Sorry about the long post, but I wasn't sure how to describe this.
    Does anyone know if such a control exists?

    Thanks,
    Erick
     
    Erick T, Aug 7, 2003
    #1
    1. Advertising

  2. Erick T

    Tommy Guest

    http://www.infragistics.com/products/grids.asp

    The above grid has the presentation layer you're looking. Not too sure
    about the logic behind it. Hope this helps.

    Tommy,

    (Erick T) wrote in message news:<>...
    > Hello,
    >
    > I am looking for a Web UI Control, either commercial or free. I don't
    > know exactly what to call it, so I will describe what I need it to do.
    > In a nutshell, it's a control to visually represent an intersection
    > table in a many-to-many relationship. For example, in this ERD
    >
    > Country ----< CountryVisit >---- Person
    >
    > each country can have more then one person visiting, and each person
    > can visit more then one country. What I want to have is a way to
    > display/edit information for the association/intersection table; all
    > possible records shown with one end fixed (either all Countries for a
    > person, or vise versa). The CountryVisit (or intersection) table could
    > have a number of fields
    >
    > CountryID
    > PersonID
    > DateOfVisit
    > etc
    >
    > So the control needs to behave like the DataGrid, where you can define
    > a template for the items to be displayed. So if my countries were
    > (USA, Canada, UK) I could fix the Person, and the control would show
    > (for example) (aircode, but if anything doesn't make sense, let me
    > know)
    >
    > <ItemTemplate>
    > <asp:checkbox checked=<%
    > IsNull(Container.DataItem("Item.CountryID")) %> Text=<%
    > Container.DataItem("Item.CountryName") %> />
    > </ItemTemplate>
    >
    > and the ItemTemplate would repeat for all possible Countries. Also,
    > the control would have events for when a row in the intersection table
    > is created or deleted, so I could set the columns as needed.
    >
    > The reason I want this control is that a lot of my databases have
    > large numbers of these intersections tables. And I seem to end up
    > writing the same code over and over again. What I generally write is
    > below.
    >
    > I need a method in my code behind to correctly populate the List,
    > which is called when the elements of the page are DataBound. e.g.,
    >
    > <asp:CheckBoxList id="checkBoxList" DataSource = "Country" etc />
    >
    > and in the codebehind:
    >
    > CountryVisitView.Filter = "PersonID = " + someID;
    > foreach (CountryVisitRow r in CountryVisitView) {
    > list.FindItem(r.CountryID).Checked = true;
    > // set other properties (date, etc)
    > }
    >
    > Then, in my update method, I often end up doing something like this,
    > which simply syncs the contents of the list to the recordset.
    >
    > CountryVisitView.Filter = "PersonID = " + someID;
    > // find newly added rows in intersection
    > foreach (Item i in checkBoxList) {
    > if (i.Checked == true) {
    > // or method which loops over the view
    > if (!CountryVisitView.Contains(i.CountryID)) {
    > // add row to CountryVisitView
    > }
    > }
    > if (i.Checked == false) {
    > if (!CountryVisitView.Contains(i.CountryID)) {
    > // remove row from country view
    > }
    > }
    > }
    >
    > What I would like, is something like
    >
    > <IdealControl
    > IntersectDataSource="CountryVisit"
    > Relationship1Name="CountryVisitCountry">
    > Relationship2Name="CountryVisitPerson"
    > Fixed="PersonID=123"
    > OnAdd="AddIntersectRec"
    > OnRemove="RemoveIntersectRec"
    > >

    > <ItemTemplate>
    > <asp:CheckBox ... > etc
    > // with DataItem a reference to the current
    > DataRow/DataRowView of the intersection table
    > </ItemTemplate>
    > </IdealControl>
    >
    > Then, the OnAdd/OnRemove events would work like the ADO.NET
    > SqlRowUpdating event, where I can inspect/update/cancel the pending
    > operation (the addition or removal of the row in the Intersection
    > table). I hope this makes sense, if not, let me know and I'll answer
    > anything I can.
    >
    > Sorry about the long post, but I wasn't sure how to describe this.
    > Does anyone know if such a control exists?
    >
    > Thanks,
    > Erick
     
    Tommy, Aug 8, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Erick T
    Replies:
    1
    Views:
    341
    Tommy
    Aug 8, 2003
  2. Natty Gur
    Replies:
    0
    Views:
    2,584
    Natty Gur
    Jun 6, 2004
  3. =?Utf-8?B?VHJldm9yIEJlbmVkaWN0IFI=?=
    Replies:
    0
    Views:
    2,397
    =?Utf-8?B?VHJldm9yIEJlbmVkaWN0IFI=?=
    Jun 7, 2004
  4. Patrick Kowalzick
    Replies:
    5
    Views:
    477
    Patrick Kowalzick
    Mar 14, 2006
  5. CNkid
    Replies:
    0
    Views:
    806
    CNkid
    Jan 15, 2010
Loading...

Share This Page