Is there an available web control like this?

E

Erick T

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top