jqGrid/MVC: How to add a static value to a column

Posted on 2011-05-06
Last Modified: 2012-06-21

I want to know how to add a static value to a column of jqGrid in MVC project.
I want to be able to implement the following sample using jqGrid, and I need help with adding value "static column" to each row:

- aspx code:
<asp:GridView ID="gvResult" runat="server" AutoGenerateColumns="false">
                <asp:BoundField HeaderText="c1" DataField="c1" />
                        static column                    

- Code behind:
protected void Page_Load(object sender, EventArgs e)
            DataTable dt = new DataTable();
            dt.Columns.Add("c1", typeof(string));

            for (int i = 0; i < 5; i++)
                DataRow dr = dt.NewRow();
                dr["c1"] = i;

            gvResult.DataSource = dt;

- Result:
 Desired Result
Question by:fippif
    LVL 27

    Expert Comment

    first of all, why are you using a gridview in your example?
    Are you planning to use webform controls in MVC?
    jQgrid doesnt care where the data comes from, your server code will send it and it will comply.
    look into the grid implementations
    look at this simple example

    Accepted Solution

    I was able to resolve my issue by using Formatter.

    Author Closing Comment

    I found the answer I was looking for by myself.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now