.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

MVC2 Convention for Many-to-Many Relationship and Checkbox List?

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :ASP.Net

I have a many-to-many relationship in my database (and Entity Framework Model) as follows:


Can anyone tell me the convention for creating a list of checkboxes for Data Admin that my users can select to fill the USER_DATA_ADMIN table?

(kind of new to MVC2)


View Complete Post

More Related Resource Links

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

How to Add A Scroll bar to ChecKbox List

Can any1 guide me to add scrollbar to checkboxlist Regards Chandrakant 

checkbox list help!!!

How can   I make the following code shorter and more efficient.  Goal:  I want to loop through the check box list for all true values.   I want to get the check list item and complare with database value then check the box.                For Each xList As ListItem In cblGroupDiningOptions.Items                        If xList.Text = "Meals_List" Then                            If eContentItems.Meals_List = True Then                                xList.Selected = True                           End If                        End If                 &n

Object reference not set to an instance of an object in Nested Repeater Control of CheckBox List con

 if ((item.ItemType == ListItemType.Item) || (item.ItemType == ListItemType.AlternatingItem))
                Repeater rptsub = (Repeater)item.FindControl("rptsub");
                CheckBoxList Chksub = (CheckBoxList)rptsub.FindControl("Chksub");
                Label lblsubroot = (Label)rptsub.FindControl("lblsubroot");
                DataRowView row = (DataRowView)e.Item.DataItem;
                RootId = Convert.ToInt32(row["IdApplication"].ToString());
                MetadataPermissions metadataPermissions = new MetadataPermissions(); ;
                DataSet rptRootValues = new DataSet();
                rptRootValues = metadataPermissions.GetrptSubMenus(RootId);
                DataRow[] drows = rptRootValues.Tables[0].Select("IdApplicationroot = " + row["IdApplication"].ToString());
                foreach (DataRow chkpermsns in drows)
                   ListItem li = new ListItem(chkpermsns["PermissionName"].ToString());


<asp:Repeater ID="rptroot" runat="server" OnItemDataBound="rptroot_ItemDataBound">

Custom Page Template (List.aspx) - one to many relationship


Hi, I have two tables which is Customer and Customer Details table, with one to many details.

Is there possible to show Child table's column in (done in one GridView) Customers/Lisp.aspx?

Filtering with Multiple selections (Checkbox list control)

I have a scenario where there is a large list of 2000+ items, these items each have a name associated to it.

I now need to be able to filter this list by selecting the names from a Checkbox list, the problem is I cannot figure out how to get it to work when multiple values are selected.

The current setup is Using a DVWP to display the items a Datasource control of all the names and then the ASP.NET Checkbox list control to act as a filter

Can anyone help?

using a checkbox list and Table Valued Parameters


I have a checkboxlist that gets all all the items from a look up table. The user is going to go to the list, check certail items and insert the checkboxid, the value (0 or 1),  and the userid  into a table valued paramater using a stored procedure. I have the user defined table type created but thats about it. Any body out there have any hints.

update dynamic checkbox list


Hi there .. on page load I fill a repeater with checkboxes. I use a separate tablelist (subcatID & userID) to check if chkbox is checked or not.

On pageload and works fine (according boxes are checked):

For i = 0 To rptFavorites.Items.Count - 1
                Dim subcatID As Label = DirectCast(rptFavorites.Items(i).FindControl("lblSubcatID"), Label)
                Dim available As Label = DirectCast(rptFavorites.Items(i).FindControl("lblAvailable"), Label)
                Dim chksubcat As CheckBox = DirectCast(rptFavorites.Items(i).FindControl("chkSubcat"), CheckBox)

                Dim conn3 As New SqlConnection(ConfigurationManager.ConnectionStrings("VCConnString").ConnectionString)
                Dim cmd3 As New Data.SqlClient.SqlCommand("Select * From tbl_interest where userID=@userID and subcategory=@subcategory", conn3)
                cmd3.Parameters.AddWithValue("@userID", "28")
                cmd3.Parameters.AddWithValue("@subcategory", subcatID.Text)
                Dim myReader3 As Data.SqlClient.SqlDataReader
                myReader3 = cmd3.ExecuteReader()
                If myReader3.Read() Then
                    chksubcat.Checked = True
                    available.Text = "Y"

Client-side checkbox list validator?


I've looked at these:



but these both work server-side (unless I'm missing something). I had hopes for the second one because it embeds javascript.

I have other validators on the page, and I want to show everything at once.  But the other ones are client-side, while the two I tried don't show the error message until the page posts back.

How do I store a list of checkbox choices in the DB most efficiently?


I'm not expecting a full solution here (unless you really want to), just some tips and pointers.

I have a User table and an Area table. The User table has userID, userName etc., and the Area table has areaID, areaName etc.
I'm binding the list of Areas to a checkboxlist where the user MUST choose between 1-3 options. I'm using a stored procedure to update the DB.

Is there a common solution to this problem that I haven't found?

I have thought about saving it as a comma separated string in a field in the user table. This looks like a temporary and ugly solution though, do you think?

A nicer solution would be to create a UserArea table where I save the ID's as foreign keys from areaID and userID. But I don't know how to write this stored procedure where I update and insert the choices made.
This way would also help me when I need to get statistics, plus it's moer scalable, I think.

Any help is greatly appreciated!


ListData.svc REST API can't navigate relationship to lookup list in parent site


I have created a list in the root web that contains common information used by multiple sites throughout the site collection.  I have also created a site column that is a lookup column which pulls from that list.  This way, I can add the site column to any list in any sub site in the site collection. 

I have a list in a sub site in the same site collection that I have added the root web site column to and, from the UI perspective, everything works great.  I can add a list item to the sub site list and select an item from the root web list for that column. 

However, if I generate a strongly typed data context and associated classes using a Visual Studio service reference to ListData.svc (or if I just play around with the REST XML in the browser), the class property which represents the lookup column in the sub site list only contains the ID of the lookup item, not a reference to an instance of the item. 

I understand that the experience getting list information from a different site is usually less than optimal but are there any workarounds to get a reference to that lookup list item via the REST API?

accessing checkbox list from with in edit item template.


Protected Sub dsEmployeesByDepartments_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
        'Determine which checkboxes have been checked
        Dim selectedDepartmentIDs As New List(Of String)
        For Each li As ListItem In CategoryList.Items
            If li.Selected Then

Add Related/Child List Item? - How to automatically set the relationship?




I've got a parent/child relationship between two lists.  I have the parent form set to automatically include child records.

The problem I'm having is that when I "Add new item," it is not associating the new record with the parent record automatically.

How do I have it automatically set the key field?

Thanks in advance for any suggestions,




Cannot enforce relationship behavior on Event List


I have an event list, to which I have added a Lookup column.  I want to enforce relationship behavior between the two lists.  (Specifically, I want to enforce cascading delete, but I encounter the same problem if I try Restrict Delete instead.)  When I try to do so, I get the following error:

[COMException (0x8107059f): <nativehr>0x8107059f</nativehr><nativestack></nativestack>This lookup field cannot enforce a relationship behavior because this list contains incompatible fields.]

Using the same lookup field on other lists, it works fine; I have only encountered this problem on an event list.  How can I avoid this error, or at least figure out which field is incompatible?


How to create a dynamic list of checkbox controls in Infopath


I am relatively new to sharepoint, and since I do not yet have a proper development environment in my current contract, I have had to attempt to produce solutions to various line of business problems using Nintex and Infopath alone.  They are working on getting one created for me but i still can't believe microsoft make you purchase a whole other sharepoint server licence unless you think developing directly on the live server is a good idea, but I digress, thats not the issue I need assistance with.

The current issue I am trying to find a solution for, or atleast the right way to approach, is the creation of a simple form where the user can check off a register of daily tasks completed and submit the form back to sharepoint from a tablet PC.  Each submission is to create a new entry in the DailyRegister list with a handful of other fields like who, where, when, etc.

That is the easy part that I was able to produce with relative ease, but where it gets tricky is they want the list of tasks to be dynamic. 

i.e. A separate sharepoint list that will just hold the list of currently relevant tasks to be included in the form for that day.  Effectively using a 3rd list as the relational reference table between the DailyRegister list and the AvailableTasks list.

I am planning to create the AvailableTasks list to look something like:

how to compare to check box list and show selected in first checkbox list


how to show first check box chkched which in show in second check box list

 <table> <tr> <td> <b>Author</b> </td> <td> <b>Reader</b> </td> </tr> <tr> <td> <div style="BORDER: thin solid; OVERFLOW: auto; WIDTH: 200px; HEIGHT:200px"> <table id="Chklist_Author" border="0"> <tr> <td><input id="Chklist_Author_0" type="checkbox" name="Chklist_Author$0" /><label for="Chklist_Author_0">Select</label></td> </tr><tr> <td><input id="Chklist_Author_1" type="checkbox" name="Chklist_Author$1" /><label for="Chklist_Author_1">1029.Aarti</label></td> </tr><tr> <td><input id="Chklist_Author_2" type="checkbox" name="Chklist_Author$2" /><label for="Chklist_Author_2">1025.Akash

checkbox list ,requried field validator


I have code

<div id="list" class="right_txt_space_accm">
											<table width="100%" border="0" cellspacing="0" cellpadding="0">
												<td  align="left"><strong></strong>
                                                    <asp:CheckBoxList ValidationGroup="testGroup" RepeatColumns=3 RepeatDirection=Horizontal ID="CheckBoxList1" runat="server">
                                                        <asp:ListItem Value="1">Cutomer Broker</asp:ListItem>
                                                        <asp:ListItem Value="2">N.V.O.C.C</asp:ListItem>
                                                        <asp:ListItem Value="3">Hauloiers</asp:ListItem>
                                                        <asp:ListItem Value="4">Air Freight</asp:ListItem>
                                                        <asp:ListItem Value="5">Sea Freight</asp:ListItem>
                                                        <asp:ListItem Value="6">Supply Chain Management</asp:ListItem>
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend