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

  • SEARCH
  • Home
  • 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 8175277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:43:14+00:00 2026-06-06T22:43:14+00:00

I tries to fill webgrid using one answered question and an article , But

  • 0

I tries to fill webgrid using one answered
question
and an article, But I can not my all rows repeat same as value. All rows values are the same as others. I have been debugging to solve this strange problem. But I can not:

public class MyViewModel
{
    public IEnumerable<string> Columns { get; set; }
    public IEnumerable<dynamic> Values { get; set; }
    public bool HasNext { get; set; }
    public bool HasPrevious { get; set; }
}

public class JobController : Controller
{
    public ActionResult Index(int? page)
    {
        ViewData["Customers"] = new SelectList(CustomerOperation.GetCustomers().Items, "Id", "Name", null);
        ViewData["Jobs"] = new SelectList(JobOperation.GetCustomersAssemblyList().Items, "scheduleId", "name", null);
        const int pageSize = 10;
        ViewBag.CurrentPage = (page ?? 0);
        if (Session["CustomerId"]!=null && Session["ScheduleId"]!=null)
        {
            int customerId = ConvertUtil.ToInt(Session["CustomerId"]);
            int scheduleId = ConvertUtil.ToInt(Session["ScheduleId"]);
            var model = GetPagedVals((page ?? 0) * pageSize, pageSize, customerId, scheduleId);
            ViewBag.HasPrevious = model.HasPrevious;
            ViewBag.HasMore = model.HasNext;

            return View(model);
        }
        else
            return View();
    }
 public MyViewModel GetPagedVals(int skip, int take, int Id, int scheduleId)
   {
       Session["CustomerId"] = Id;
       Session["ScheduleId"] = scheduleId;
       DataTable dt = JobOperation.GetJobsBySchedulerIdAndCustomerId(scheduleId, Id);
       List<dynamic> dataList = new List<dynamic>();
       dynamic expando = new ExpandoObject();
       var p = expando as IDictionary<String, object>;

       IEnumerable<string> columnNames = dt.Columns.Cast<DataColumn>().Select(x => x.ColumnName);
       foreach (DataRow dr in dt.Rows)
       {
           foreach (string columnName in columnNames)
           {

               p[columnName] = ConvertUtil.ToString(dr[columnName]);

           }
           dataList.Add(expando);
        }

       var result = dataList.Skip(skip).Take(take).ToList();
       var model = new MyViewModel();
       model.Columns = columnNames;
       model.Values = result;
       model.HasNext = (skip + 10 < dataList.Count);
       model.HasPrevious = (skip > 0);
       ViewBag.HasPrevious = model.HasPrevious;
       ViewBag.HasMore = model.HasNext;

       return model;
   }

Result is below:

enter image description here

But All row is the same as anthers! Result must be below :
enter image description here
My sql queries working good. No problem sql. My repeated rows last row. How to solve this strange problem.

  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-06-06T22:43:15+00:00Added an answer on June 6, 2026 at 10:43 pm
    dynamic expando = new ExpandoObject();
    

    You only ever create one ExpandoObject instance.
    You add this same instance to the list once for each row, overwriting the properties each time.

    You need to create a new instance for each row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure if this is an appropriate forum to ask this question, but I've
My android aplication tries to connect to a service using response = client.execute(getRequest); However
This is a newbie question to AJAX experts: In case an unauthenticated user tries
How time consuming is it to move a website built using Webforms to one
Well... I am trying to create an application using the TTS Engine. I can
I have an accordion that on load gets data using ajax to fill it
I tried searching here for a similar solution but didn't see one so I
I already tried asking this question at Relative layout Coding , but that first
I tried following code but I couldn't find success messages from it.Here commandText can
I tries to delete an entity - table This is the code: db.Sessions.SqlQuery(delete table

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.