Q:

Get data from query string asp.net mvc

I have the following method in controller.
public class CompaniesController : ApiController
{

    static IList<Models.ClientCompany> list = new List<Models.ClientCompany>();

    public object Get(int skip)
    {

        list.Clear();
        var queryString = HttpContext.Current.Request.QueryString;
        int skip = Convert.ToInt32(queryString["$skip"]);
        int take = Convert.ToInt32(queryString["$top"]);
        int countPages = 0;

        list.Add(new Models.ClientCompany(1, "Krzak"));
        list.Add(new Models.ClientCompany(2, "Agrawka"));
        list.Add(new Models.ClientCompany(3, "Filut"));
        list.Add(new Models.ClientCompany(4, "Beczka"));
        list.Add(new Models.ClientCompany(5, "Progress"));
        if (take == 0)
        {
            countPages = list.Count;
            take = list.Count;
        }

        if (queryString["$inlineCount"] != null)
        {
            string allPages = queryString["$inlineCount"].ToString();
            countPages = list.Count;
        }
        return new {
            Items = list.Skip(skip).Take(take),Count=countPages
        };
    }

}

I want use something instead of QueryString to identify parameter skip in headline method. Like this.
public object Get([some attribute]int skip)

Example of request.
api/cmp/?$inlinecount=allpages&$orderby=cmpn%20desc&params=[object%20Object]&$skip=4&$top=2

A:

We can get data from query string by passing additional parameter through addParams method of ejQuery. Please refer the below KB link for passing parameter to controller method
https://www.syncfusion.com/kb/7865/how-to-pass-additional-parameter-when-using-datamanager-in-grid
If you still face difficulties, please share us some details like whether you are binding data to Grid through datamanager . If not, what are the controls used in your project so that we can proceed further.
Regards,
Keerthana.

