Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 186029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:34:31+00:00 2026-05-11T15:34:31+00:00

I have a view that uses a strongly typed ViewData similar to this: namespace

  • 0

I have a view that uses a strongly typed ViewData similar to this:

namespace Site.web2.Models {     public class MySubData     {         public string Note { get; set; }         public bool IsValid { get; set; }     }     public class MyViewData     {         public int DataId { get; set;}         public List<MySubData> SubData { get; set; }          public MyViewData()         {         }          public void LoadDummyData()         {             DataId = 42;             SubData = new List<MySubData>();             SubData.Add(new MySubData() { Note = 'Item 1' });             SubData.Add(new MySubData() { Note = 'Item 2' });         }     } } 

Controller:

[AcceptVerbs(HttpVerbs.Get)] public ActionResult Test1() {     Site.web2.Models.MyViewData data = new Site.web2.Models.MyViewData();     data.LoadDummyData();     return View(data); }  [AcceptVerbs(HttpVerbs.Post)] public ActionResult Test1(Site.web2.Models.MyViewData data) {     return RedirectToAction('Index'); } 

And the View is like this:

<%@ Page Title='' Language='C#' MasterPageFile='~/Content/Site.Master'      Inherits='System.Web.Mvc.ViewPage<Site.web2.Models.MyViewData>' %> <%= Html.BeginForm<HomeController>(c => c.Test1(null)) %> <p>Id:</p> <p><%= Html.TextBox('DataId')%></p> <p>Note 1:</p> <p><%= Html.TextBox('SubData[0].Note')%></p> <p>Note 2:</p> <p><%= Html.TextBox('SubData[1].Note')%></p>  <input type='submit' value='Submit' /> <% Html.EndForm(); %> 

Ok, if I create a MyViewData, call LoadDummyData(), and use that in a View, I don’t see my data in the TextBoxes.

The funny thing is, if I enter data in to the TextBoxes, that will get populated into the returned MyViewData in the Post controller.

What am I doing wrong? Was this fixed in a later version of MVC? I think I have RC 1.

Keith

Update 1

This

<%= Html.TextBox('DataId')%> 

works just fine. I guess my question is, should this

<%= Html.TextBox('SubData[0].Note')%> 

work the same way?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:34:32+00:00Added an answer on May 11, 2026 at 3:34 pm

    Try this:

    <p>Id:</p> <p><%= Html.TextBox('DataId', Model.DataId)%></p> <p>Note 1:</p> <p><%= Html.TextBox('SubData[0].Note', Model.SubData[0].Note)%></p> <p>Note 2:</p> <p><%= Html.TextBox('SubData[1].Note', Model.SubData[1].Note)%></p> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple viewmodel class, and a strongly typed view (which uses
I have a view that uses a list of modelitems like this: List<It4You.AlertBrick.Library.Domain.Order.AbOrderLineItemPicked> When
I have some view controller, that uses my own view class and XIB interface,
I have a web site in asp.net that uses a master page. In this
I have a view that uses one of the class-based generic views (derives from
I have a view model that is displayed in a view that uses uploadify.
I have a partial view that uses a Telerik MVC Grid, and it has
I have used a list view that uses a grid view in WPF. I
I have a controller's action and view page that uses a master page. The
I have a custom view in my Android App that uses a ScaleGestureDetector.SimpleOnScaleGestureListener to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.