Click here to Skip to main content
15,917,731 members
Home / Discussions / C#
   

C#

 
GeneralRe: Invalid column name 'NoteTotal' , how to fix it to this error in Sql server Pin
Eddy Vluggen5-May-18 7:43
professionalEddy Vluggen5-May-18 7:43 
GeneralRe: Invalid column name 'NoteTotal' , how to fix it to this error in Sql server Pin
Gerry Schmitz5-May-18 7:44
mveGerry Schmitz5-May-18 7:44 
QuestionI need to get the next next text from text file Pin
Mohamed Fahad M5-May-18 3:04
Mohamed Fahad M5-May-18 3:04 
AnswerRe: I need to get the next next text from text file Pin
Richard MacCutchan5-May-18 3:21
mveRichard MacCutchan5-May-18 3:21 
AnswerRe: I need to get the next next text from text file Pin
OriginalGriff5-May-18 3:27
mveOriginalGriff5-May-18 3:27 
AnswerRe: I need to get the next next text from text file Pin
Gerry Schmitz5-May-18 4:35
mveGerry Schmitz5-May-18 4:35 
QuestionOpenTK and text Pin
Leif Simon Goodwin4-May-18 5:39
Leif Simon Goodwin4-May-18 5:39 
QuestionBind JSON data to rows in a table MVC4 issue Pin
Member 127814644-May-18 4:06
Member 127814644-May-18 4:06 
I need help with binding JSON data generated from REST API call to rows in a table in MVC.Below is the code for Controller
C#
public ActionResult Members()
{
var jsonString = "{\"roleMappings\":[{\"user\":{\"id\":\"4b147d87-64eb-4049-bbd3-ade96d18af89\",\"name\":\"PFRENC17\",\"actualName\":\"French, Phil (P.)\",\"displayName\":\"French, Phil (P.) (PFRENC17)\",\"email\":\"pfrenc17@abc.com\",\"deleted\":false,\"deletedDate\":0,\"authenticationRealm\":\"f4191d4b-4331-4637-af6f-c89781687bf6\",\"isLockedOut\":false,\"lastLoginDate\":1502803623890,\"isDeletable\":true},\"role\":{\"id\":\"3de854ce-34ed-4b7f-9b99-9fdf04c0345c\",\"name\":\"Developer\",\"description\":\"Application Developer\",\"isDeletable\":true}},{\"user\":{\"id\":\"3afd930e-9608-4257-a962-0a82b792a6e9\",\"name\":\"RSIEGLE3\",\"actualName\":\"Siegler, Ryan (R.)\",\"displayName\":\"Siegler, Ryan (R.) (RSIEGLE3)\",\"email\":\"rsiegle3@abc.com\",\"deleted\":false,\"deletedDate\":0,\"authenticationRealm\":\"f4191d4b-4331-4637-af6f-c89781687bf6\",\"isLockedOut\":false,\"lastLoginDate\":1500300166062,\"isDeletable\":true},\"role\":{\"id\":\"3de854ce-34ed-4b7f-9b99-9fdf04c0345c\",\"name\":\"Developer\",\"description\":\"Application Developer\",\"isDeletable\":true}},{\"user\":{\"id\":\"33dd9fea-4685-4505-91ba-5c0508301b56\",\"name\":\"Michael3\",\"actualName\":\"Michael (Y.)\",\"displayName\":\"Michael (Y.) (Michael3)\",\"email\":\"Michael3@abc.com\",\"deleted\":false,\"deletedDate\":0,\"authenticationRealm\":\"f4191d4b-4331-4637-af6f-c89781687bf6\",\"isLockedOut\":false,\"lastLoginDate\":1522249840141,\"isDeletable\":true},\"role\":{\"id\":\"f722b338-01c1-43cb-bc53-853cfb0d2249\",\"name\":\"UC Auto Discovery\",\"description\":\"\",\"isDeletable\":false}},{\"user\":{\"id\":\"33dd9fea-4685-4505-91ba-5c0508301b56\",\"name\":\"Michael3\",\"actualName\":\"Michael (Y.)\",\"displayName\":\"Michael (Y.) (Michael3)\",\"email\":\"Michael3@abc.com\",\"deleted\":false,\"deletedDate\":0,\"authenticationRealm\":\"f4191d4b-4331-4637-af6f-c89781687bf6\",\"isLockedOut\":false,\"lastLoginDate\":1522249840141,\"isDeletable\":true},\"role\":{\"id\":\"8421e59e-ce5f-477b-aa6f-0313aa1223e6\",\"name\":\"Application_Lead\",\"description\":\"Development Team Lead\",\"isDeletable\":true}},{\"user\":{\"id\":\"5599437f-68f9-4c20-bd0a-5c26d55628e1\",\"name\":\"UBLDUCD1\",\"actualName\":\"Blducd1, U (U.)\",\"displayName\":\"Blducd1, U (U.) (UBLDUCD1)\",\"deleted\":false,\"deletedDate\":0,\"authenticationRealm\":\"f4191d4b-4331-4637-af6f-c89781687bf6\",\"isLockedOut\":false,\"lastLoginDate\":1515694447960,\"isDeletable\":true},\"role\":{\"id\":\"8421e59e-ce5f-477b-aa6f-0313aa1223e6\",\"name\":\"Application_Lead\",\"description\":\"Development Team Lead\",\"isDeletable\":true}},{\"group\":{\"id\":\"7862c275-8eb2-42cf-895c-214c2826a0b8\",\"name\":\"config_viewer\",\"enabled\":true},\"role\":{\"id\":\"ba4cdbf1-6b97-436f-9b40-a7e21d8394f2\",\"name\":\"ReadOnly\",\"description\":\"Read-only access\",\"isDeletable\":true}}],\"id\":\"877eb9b9-6dd9-432d-b55a-01bd406d039a\",\"name\":\"AftImport Team\",\"isDeletable\":true}";

            List<string> MemberNames = new List<string>();
           

            var t = JObject.Parse(jsonString);
            
            var pt = t["roleMappings"];
            var COUNT = 0;
            foreach (var v in pt)
            {
                if (COUNT > 4)
                {
                    break;
                }
                var p = v["user"]["name"];
                MemberNames.Add(p.ToString());
                COUNT++;
            }
return View(MemberNames);
}


Below is the code for View
<table border="1" align="center" style="font-family:Arial; width:900px;">
    <tr height="50">
        <th>Member</th>
        <th>Roles</th>
        <th>Actions</th>
    </tr>
    @foreach (var d in Model)
    {
        
        <tr height="30">
            <th>@d</th>
            <th></th>
            <th><button class="editbtn">Delete User</button>  <button class="editbtn">Change Role</button></th>
        </tr>

        }
  
</table>

As I have binded json data to the "Member" field in View to the Controller, I need help with binding "Roles" field in View to
"name": "Application_Lead",
. I need Roles to be displayed on web page. Typical roles in the above JSON string are "Developer", "Application Lead"
AnswerRe: Bind JSON data to rows in a table MVC4 issue Pin
Afzaal Ahmad Zeeshan4-May-18 8:21
professionalAfzaal Ahmad Zeeshan4-May-18 8:21 
GeneralRe: Bind JSON data to rows in a table MVC4 issue Pin
Member 127814647-May-18 4:32
Member 127814647-May-18 4:32 
Questionc# GridView. Displaying tables in dropdownlist, selecting and editing them. Pin
trottl4-May-18 2:07
trottl4-May-18 2:07 
AnswerRe: c# GridView. Displaying tables in dropdownlist, selecting and editing them. Pin
Gerry Schmitz5-May-18 4:39
mveGerry Schmitz5-May-18 4:39 
GeneralRe: c# GridView. Displaying tables in dropdownlist, selecting and editing them. Pin
trottl10-May-18 0:47
trottl10-May-18 0:47 
GeneralRe: c# GridView. Displaying tables in dropdownlist, selecting and editing them. Pin
trottl10-May-18 1:15
trottl10-May-18 1:15 
AnswerRe: c# GridView. Displaying tables in dropdownlist, selecting and editing them. Pin
trottl14-May-18 1:59
trottl14-May-18 1:59 
QuestionC# Newbie - Vector Printing of Visio Document using AxVisioViewer ActiveX control. Pin
chubbsy1-May-18 23:02
chubbsy1-May-18 23:02 
AnswerRe: C# Newbie - Vector Printing of Visio Document using AxVisioViewer ActiveX control. Pin
Eddy Vluggen2-May-18 7:36
professionalEddy Vluggen2-May-18 7:36 
GeneralRe: C# Newbie - Vector Printing of Visio Document using AxVisioViewer ActiveX control. Pin
chubbsy22-May-18 1:46
chubbsy22-May-18 1:46 
GeneralRe: C# Newbie - Vector Printing of Visio Document using AxVisioViewer ActiveX control. Pin
Eddy Vluggen22-May-18 1:48
professionalEddy Vluggen22-May-18 1:48 
QuestioniTextSharp - Saving file to a remote server Pin
User 136751141-May-18 22:21
User 136751141-May-18 22:21 
AnswerRe: iTextSharp - Saving file to a remote server Pin
Jochen Arndt2-May-18 1:46
professionalJochen Arndt2-May-18 1:46 
GeneralRe: iTextSharp - Saving file to a remote server Pin
User 136751142-May-18 1:50
User 136751142-May-18 1:50 
GeneralRe: iTextSharp - Saving file to a remote server Pin
Jochen Arndt2-May-18 2:00
professionalJochen Arndt2-May-18 2:00 
QuestionSIMD Experiment (System.Numeric.Vectors.Vector2 test) Pin
Super Lloyd29-Apr-18 16:12
Super Lloyd29-Apr-18 16:12 
AnswerRe: SIMD Experiment (System.Numeric.Vectors.Vector2 test) Pin
Jochen Arndt1-May-18 23:41
professionalJochen Arndt1-May-18 23:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.