Click here to Skip to main content
16,017,986 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends,
I am using MVC 2.0.

I have a problem that I want to get data in my view for two tables.

data from table1 is needed to fill my grid.

and data from table 2 to provide user the choices of items that i have in another table(I want to show item as checkbox for selecting).
I have no idea how can I do this task.

can you please help me on this.
Posted
Updated 29-May-10 4:43am
v2

Why don't you join the two tables using a JOIN clause. If you want to show related table data together, there must be a key that should be common to both tables.
 
Share this answer
 
Neo Arora wrote:
and data from table 2 to provide user the choices of items that i have in another table(I want to show item as checkbox for selecting)


If you have more than two choices it is going to be very difficult to use a CheckBox to represent them. Do you not think that you would be better to use a ComboBox?
 
Share this answer
 
Hi,

Actually normal html code doesn't support checked list box. So ur need is not get by normal condition.

Please try this.

in controller

VB
Function CheckBox() As ActionResult

            Dim strCheckBoxGroup As String
            strCheckBoxGroup = "<table border='1'> "
            For x As Integer = 1 To 10
                strCheckBoxGroup = strCheckBoxGroup + " <tr> "
                strCheckBoxGroup = strCheckBoxGroup + " <td> "
                strCheckBoxGroup = strCheckBoxGroup + " <input id='" + x.ToString + "' name='" + x.ToString + "' type='checkbox' value='true' />"
                strCheckBoxGroup = strCheckBoxGroup + x.ToString + " Description "
                strCheckBoxGroup = strCheckBoxGroup + " </td> "
                strCheckBoxGroup = strCheckBoxGroup + " </tr> "
            Next
            strCheckBoxGroup = strCheckBoxGroup + " </table>"
            ViewData("chkBox") = New HtmlString(strCheckBoxGroup)
            Return View(ViewData("chkBox"))
        End Function



In View

XML
<body>
<%
    Html.BeginForm()
    If True Then
    %>
    <div>
        <%: ViewData("chkBox")%>
    </div>
    <% End If%>

</body>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900