[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-05-06
3
Medium Priority
?
1,819 Views
Last Modified: 2012-06-21

I want to know how to add a static value to a column of jqGrid in MVC project.
Example:
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">
            <Columns>
                <asp:BoundField HeaderText="c1" DataField="c1" />
                <asp:TemplateField>
                    <ItemTemplate>
                        static column                    
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>


- 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;
                dt.Rows.Add(dr);
            }

            gvResult.DataSource = dt;
            gvResult.DataBind();
        }

- Result:
 Desired Result
0
Comment
Question by:fippif
  • 2
3 Comments
 
LVL 27

Expert Comment

by:Sammy Ageil
ID: 35739197
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 http://bartreyserhove.blogspot.com/2008/08/aspnet-mvc-and-jqgrid.html
0
 

Accepted Solution

by:
fippif earned 0 total points
ID: 35744149
I was able to resolve my issue by using Formatter.
0
 

Author Closing Comment

by:fippif
ID: 35767727
I found the answer I was looking for by myself.
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

868 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