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


I have a grid with 4 columns 'id' name 'address' and all the IDs in the list and grid For binding Now I am getting the name based on the ID of the grid_item databout event, the address age for that particular line I now want to sort the grid by name. How can I sort by name, which was tied to the grid in the item Dathbong

My code

  grdEmployee.DataSource = lstEmployee.OrderBy (x = & Gt; x.Id) .toList (); Protected Zero grdEmployee_ItemDataBound (Object Sender, EventArgs e) {label lblname = (label) e.Row.FindControl ("lblName"); Label llge = (label) e.ro.fund control ("lllage"); Labeled LLLID = (label) e.ro.fund control ("LBLID"); LblName.Text = GetName (lblId.Text); LblAge.Text = GetAge (lblId.Text); }  

Note: This is the sample code that I myself have written in this editor. Please do not mind the flaws in the code and please understand my scenario.

I think it would be better if you get all the data in one go, then every Participate in the item data in the call. In this way, rather than a list of IDs, you will have a dataset or a list of employees. And then you can sort this DataTable or by the way you like - using DefaultView.Sort (for DataTable) or using LINQ OrderBy.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -