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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:51:48+00:00 2026-06-15T09:51:48+00:00

I am trying to implement a CheckBoxList in my View and get the selected

  • 0

I am trying to implement a CheckBoxList in my View and get the selected list of checkbox values in a List.

I tried the example from this link, but I can’t get the selected checked list items.

My View

@foreach (var item in Model)
{
    <tr>
        <td align="center" class="Text_nocolor singleCheckbox">
            <input type="checkbox" class="checkbox" value="@item.ProductID" name="selectedObjects"/>
            @Html.HiddenFor(modelItem => item.ProductName)
        </td>
        <td align="center" class="Text_nocolor" id="myimage">
            <img src="@Url.Content(item.Imageurl)" width="40px" height="40px"  title="@item.ProductName" alt="Product"  class="myimage" style="border-style:none;"/>
        </td>
        <td align="left" class="Text_nocolor">
            @Html.DisplayFor(modelItem => item.ProductName)
        </td>
    </tr>
}
@Html.ActionLink(" ", "Checkout", new { controller = "Checkout", UserID = Request.QueryString["UserID"], Partnerid = Request.QueryString["Partnerid"] }, new { @class = "btnCheckout" })

Controller code (Index) :

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString);
public IList<CartModel> GetCartDetails(string id, string partnerid)
{
    List<CartModel> CartDetails = new List<CartModel>();
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from tablename where [User ID]='" + id + "' and [Partner ID]='" + partnerid + "'", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CartModel cartInfo = new CartModel();
                cartInfo.ProductName = dt.Rows[i]["Product Name"].ToString();
                cartInfo.Imageurl = "~/Handler.ashx?Pid=" + dt.Rows[i]["Product ID"].ToString() + "&Imgid=1&Partnerid=" + partnerid;
                CartDetails.Add(cartInfo);
            }
        }
        con.Close();
    }
    return CartDetails;
}

public ActionResult Index()
{
    id = Request.QueryString["UserID"];
    partnerid = Request.QueryString["Partnerid"];
    IList<CartModel> objshop = new List<CartModel>();
    objshop = GetCartDetails(id, partnerid);
    ViewBag.Categories = objshop.ToList();
    return View(objshop.ToList());
}

public ActionResult Checkout(string id, string partnerid, int[] categories)
{
    string id = Request.QueryString["UserID"];
    string partnerid = Request.QueryString["Partnerid"];
    //How to get the selected checked list items as a list.
    return View();
}

Any suggestions?

  • 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-15T09:51:48+00:00Added an answer on June 15, 2026 at 9:51 am

    Finally I got this through a Webgrid to get a checkboxlist.

    Refer this Blog
    http://weblogs.asp.net/imranbaloch/archive/2011/09/13/webgrid-helper-with-check-all-checkboxes.aspx

      @grid.GetHtmlWithSelectAllCheckBox(tableStyle: "webGrid",
                headerStyle: "header",
                checkBoxValue: "ProductID",
                columns: grid.Columns(
                grid.Column(columnName: "", format: @<text><img src="@Url.Content(item.Imageurl)" class="image" alt="Image "/></text>, style: "txtalignleft"),
                grid.Column(columnName: "ProductName", style: "txtalignleft"),
                grid.Column(columnName: "Quantity", style: "txtcenter"),
                grid.Column("Edit", " ", style: "txtalignleft", format: @<a href="@Url.Action("Index", "Cart", new { UserID = Request.QueryString["UserID"], partnerid = Request.QueryString["Partnerid"] })"><img
                    alt="edititem" style="vertical-align: middle; text-align: justify; border-style: none;"
                    height="17px" src="../../Images/edit.png" title="Edit" id="imgEdit" /></a>),
                grid.Column(columnName: "Rate", style: "txtalign"),
                grid.Column(columnName: "Price", style: "txtalign")
          ))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to implement this example, but with $.getScript: and for some reason, it
Trying to implement AVAudioplayer and get some metering data of the played music, but
Trying to implement the example from here. Facebook Share passes along the URL of
Trying to implement links in my foreach loop. However, can't get the $category link
Trying to implement google C2DM service. registrationIntent.putExtra(app, PendingIntent.getBroadcast(context,0,new Intent(), 0)); registrationIntent.putExtra(sender,example@gmail.com); context.startService(registrationIntent); Almost every
Trying to implement a search similar to here .This searches properties based on city,locality,property
Im trying to implement a destructor for the objects of linked-list Iv created. I
Trying to implement a function that will return a list of ints the represent
Trying to implement a modal window with CCLayer. My modal view layer is added
I am trying implement Unblock me Puzzle. i want to change image position from

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.