can I group in a webgrid using business objects as a datasource?

Legacy

A description has not yet been added to this group.

can I group in a webgrid using business objects as a datasource?

  • rated by 0 users
  • This post has 1 Reply |
  • 1 Follower
  • Hi All.  I am using a webservice to return a business object which I bind to my webgrid.

    Is there a way to use grouping with that business object as the grids datasource?

    I have been unable to find documentation on it.

    I did see that to sort you have to use a dataview.  Is that still true.

     I really don't want to create a wrapper to populate a dataset or data table every time I want to sort or group.

     

    Tx,

    Roger

  • Hi,
     
    >Is there a way to use grouping with that business object as the grids datasource?
     
    Grouping is done on the grid level, not the datasource one.
    For example:
     
    aspx:
            <c1g:C1WebGrid runat="server" ID="C1WebGrid1" AutoGenerateColumns="false">
                <Columns>
                    <c1g:C1BoundColumn DataField="ID" HeaderText="ID">
                        <GroupInfo Position="Header"></GroupInfo>
                    </c1g:C1BoundColumn>
                    <c1g:C1BoundColumn DataField="NAME" HeaderText="NAME"/>
                </Columns>
            </c1g:C1WebGrid>
     
    cs:
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }
     
        private void LoadData()
        {
            C1WebGrid1.DataSource = GetBO();
            C1WebGrid1.DataBind();
        }
     
        private object GetBO()
        {
            List<Client> clients = new List<Client>();
     
            clients.Add(new Client(0, "Client0"));
            clients.Add(new Client(1, "Client1"));
            clients.Add(new Client(2, "Client2"));
            clients.Add(new Client(3, "Client3"));
            clients.Add(new Client(4, "Client4"));
     
            return clients;
        }
     
        public class Client
        {
            private int _id;
            private string _name;
     
            public Client()
            {
            }
     
            public Client(int id, string name)
            {
                _id = id;
                _name = name;
            }
     
            public int ID
            {
                get { return _id; }
                set { _id = value; }
            }
     
            public string Name
            {
                get { return _name; }
                set { _name = value; }
            }
        }
     
    >>I did see that to sort you have to use a dataview.  Is that still true.
     
    DataView is used for automatic sorting, if you want to manually sort data, there should not be a problem.
     
    Regards,
    Sergey.
    <rmarty54> wrote: news:227943@10.0.1.98...

    Hi All.  I am using a webservice to return a business object which I bind to my webgrid.

    Is there a way to use grouping with that business object as the grids datasource?

    I have been unable to find documentation on it.

    I did see that to sort you have to use a dataview.  Is that still true.

     I really don't want to create a wrapper to populate a dataset or data table every time I want to sort or group.

     

    Tx,

    Roger



    http://helpcentral.componentone.com/cs/forums/p/81968/227943.aspx#227943

Page 1 of 1 (2 items)