Thursday 15 July 2010

c# - Sort a Grid when after loading all data in the grid -



c# - Sort a Grid when after loading all data in the grid -

i have grid 4 columns 'id' 'name' ' address' 'age' getting id's in list , binding grid. in grid_itemdatabound event depending upon id getting name, address age particular row. want sort grid depending on name. how can sort depending on name binded grid in item databound please needful

my code

grdemployee.datasource = lstemployee.orderby(x => x.id).tolist(); protected void grdemployee_itemdatabound(object sender, eventargs e) { label lblname = (label)e.row.findcontrol("lblname"); label lblage = (label)e.row.findcontrol("lblage"); label lblid = (label)e.row.findcontrol("lblid"); lblname.text = getname(lblid.text); lblage.text = getage(lblid.text); }

note: sample code have manually written in editor. please ignore faults in code , please understand scenario.

i think, improve if info @ once, doing in parts in each phone call itemdatabound. way instead of list of id have datatable or list of employees. , can sort datatable or list way - using defaultview.sort (for datatable) or linq orderby.

c# asp.net

No comments:

Post a Comment