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 8391245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:12:35+00:00 2026-06-09T19:12:35+00:00

HI all i have some values…using them i am building a string in my

  • 0

HI all i have some values…using them i am building a string in my controller i wan to display the string in my view page….

here is my controller code

[ChildActionOnly]
public ActionResult History()
{
    //if(Session["DetailsID"]!=null)
    //{
    int id = Convert.ToInt16(Session["BugID"]);
       var History = GetBugHistory(id);
      return PartialView(History);
    //}
    //int id1 = Convert.ToInt16(Session["BugID"]);
    //var History1 = GetBugHistory(id1);
    //return PartialView(History1);

}
/// <summary>
///To the List of Resolutions and Employeenames Based on BugID
/// </summary>
/// <param>Bug Id</param>
/// <returns>BugHistory</returns>       
public List<BugModel> GetBugHistory(int id)
{

    var modelList = new List<BugModel>();
    using (SqlConnection conn = new SqlConnection(ConnectionString))
    {
        conn.Open();
        SqlCommand dCmd = new SqlCommand("History", conn);
        dCmd.CommandType = CommandType.StoredProcedure;
        dCmd.Parameters.Add(new SqlParameter("@BugID", id));
        SqlDataAdapter da = new SqlDataAdapter(dCmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        StringBuilder sb = new StringBuilder();
        conn.Close();
        for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
        {
            var model = new BugModel();
            model.FixedBy = ds.Tables[0].Rows[i]["FixedByEmployee"].ToString();
            model.Resolution = ds.Tables[0].Rows[i]["Resolution"].ToString();
            model.AssignedTo = ds.Tables[0].Rows[i]["AssignedEmployee"].ToString();
            model.Status = ds.Tables[0].Rows[i]["Status"].ToString();
            model.ToStatus= ds.Tables[0].Rows[i]["ToStatus"].ToString();                  
            modelList.Add(model);
            sb.Append("'" + model.FixedBy + "'" + "has updated the status from" + "'" + model.ToStatus + "'" + "to" + "'" + model.Status + "'" + "and Assigned to" + "'" + model.AssignedTo + "'");
        }
        return modelList;
    }           
}

How should i show this string in my partial view page using a foreach loop

  • 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-09T19:12:36+00:00Added an answer on June 9, 2026 at 7:12 pm

    anil,

    I’d suggest creating a partialview (_BugModelList.cshtml) that handles purely the output display of the BugModel. This may look something like this:

    @model IList<BugModel>
    
    <table>
        <thead>
            <tr>
                <th>Fixed by</th>
                <th>From Status</th>
                <th>To Status</th>
                <th>Assigned to</th>
            </tr>
        </thead>       
        @{
            foreach (var item in Model)
            {
                <tr>
                    <td>@item.FixedBy</td>
                    <td>@item.ToStatus</td>
                    <td>@item.Status</td>
                    <td>@item.AssignedTo</td>
                </tr>
            }
        }
    </table>
    

    or, if you wanted the single string as per your controller (untested obviously):

    @model IList<BugModel>
    
    @{
        foreach (var item in Model)
        {
            <p>
                @{ "'"  + item.FixedBy + "'"
                        + " has updated the status from "
                        + "'"  + item.ToStatus + "'"
                        + " to " + "'" + item.Status + "'"
                        + " and Assigned to " + "'" + item.AssignedTo + "'"; }
            </p>
        }
    }
    

    this would then be called from your main view as per the action that you presently have. Obviously, I’ve formatted it as table but you can refactor that to suit, the logic remains the same.

    [Edit] – re-reading your question, you probably want to present the list as a table, rather than as an unordered list. See edit above

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

Sidebar

Related Questions

I have some classes that are used for Styling and all of them display
I have some strange issue using jQuery Validation plugin. Firs of all here is
I have a String with some value. I want to iterate over all classes
I have some source codes to display all file names in a UITablView I
I have some values that grab off an API and store them into an
I have retrieved some values from database. In my view file I have the
I have some values in List<SelectItem> selectedDividendYears Now I want to make a string
Hi all i have ajax where i have some data And a controller action
How do you determine if all hash keys have some value ?
I have some tables. These tables all have one column in common called 'classified_id':

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.