예제 #1
0
    public void Data(object parameters)
    {
        //Read paramater from datatable along with additional parms
        var req = DataTableParameters.Get(parameters);

        QuerySP query = new QuerySP();

        DataTable table = query.QueryData();

        DataView dv = table.DefaultView;

        //dv.Sort = "ID DESC";
        foreach (var col in req.Columns)
        {
            if (req.Order.ContainsKey(col.Key))
            {
                dv.Sort = table.Columns[req.Order[col.Key].Column].ToString() + " " + req.Order[col.Key].Direction;
            }
        }

        table = dv.ToTable();

        var resultSet = new DataTableResultSet();

        resultSet.draw            = req.Draw;
        resultSet.recordsTotal    = table.Rows.Count;
        resultSet.recordsFiltered = table.Rows.Count;

        foreach (DataRow recordFromDb in table.Select().Skip(req.Start).Take(req.Length))
        {
            //var columns = new List<string>(); // Working

            var columns = new List <string>();
            foreach (DataColumn col in table.Columns)
            {
                //columns.Add(recordFromDb[col.ColumnName].ToString()); - Working
                //columns.Add(recordFromDb[col.ColumnName] as LiteralControl);
                //columns.Add(((LiteralControl)recordFromDb[col.ColumnName]).Text);
                columns.Add(recordFromDb[col.ColumnName].ToString());
            }

            //columns.Add("<a href='https://google.com'>Link</a>");

            //columns.Add(recordFromDb[0].ToString());
            //columns.Add(recordFromDb[1].ToString());

            resultSet.data.Add(columns);
        }

        SendResponse(HttpContext.Current.Response, resultSet);
    }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     GenerateTable(query.QueryData());
 }