ASP. MVC3 WebGrid Query Bindings

Source: Internet
Author: User

Attribute interpretation

1 DataSource Gets the data source that is bound to the WebGrid

2 Totalrowcount Gets the total row count of data bound to WebGrid

3 PageIndex get WebGrid total pages

4 SortDirection Gets or sets the sort direction of the WebGrid

5 SelectedIndex Gets the index of the WebGrid selection row

public ActionResult Gridview ()
2{
3Daldatacontext da= New Daldatacontext ();
4              var result =da. T_students.tolist ();
5              this= result;
6              return View ();
7        }

1@using mvc3tutorial;
2@model List<T_student>
3@{
4View.title = "Gridview";
5Layout = "~/views/shared/_layout.cshtml";
6}
7
8@{
9var Grid = new WebGrid (Source:model,
10Fieldnameprefix: "Grid_",
11DEFAULTSORT: "Studentname",
12Canpage:true,
13Cansort:true,
14Ajaxupdatecontainerid: "Divgrid",
15PagefieldName: "Paging",
16Sortfieldname: "SortField",
17ROWSPERPAGE:10);
18
19<DivId= "Divgrid">
20@grid. Gethtml (
21stColumns:grid. Columns (
22Grid. Column ("StudentID", "Student ID"),
23Grid. Column ("Studentname", "Student Name"),
24Grid. Column ("Studentcode", "Student Code"),
25Grid. Column ("Sex", "sex"),
26Grid. Column ("Nricpassport", "Nric/passport No.")
27)
28)
29</Div>
30<H2>
31Page Count:
32@Html. Encode (grid. PageCount)
33     <br/>
34     total Record:
35     @Html. Encode (grid. Totalrowcount)
36     </h2>
Span style= "color: #008080;" >37     @Html. Encode (grid. Fieldnameprefix)
38

ASP. MVC3 WebGrid Query Bindings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.