Click to See Complete Forum and Search --> : sorting with datagrid


kmp1982
February 26th, 2008, 01:18 PM
Hi

I am reading data from XML files and then i bind those data to datagrid. When i am reading xml files i load that data into object of class and then i use string builder class

here is code.



DocumentCollection updatedDocumentCollectionPolicy = new DocumentCollection();

if(documentCollection[i].SubType.Equals(SubTypes.Policy))
{updatedDocumentCollectionPolicy.Add(documentCollection[i]);

}

dgPolicies.DataSource = updatedDocumentCollectionPolicy;

dgPolicies.DataBind();

private void dgPolicies_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) {
PopulateGrid(lnkFile, imgNewIcon, btnAdd, document);

}

public populategrid(Document document)

StringBuilder docDetails = new StringBuilder();


//docDetails.Append(document.Title);

docDetails.Append(document.SourceObjName);

docDetails.Append(" - ");

docDetails.Append(displayDate);

docDetails.Append(" - ");

docDetails.Append(document.Status); e.g status = effective



lnk.Text = Server.HtmlEncode(docDetails.ToString());

e.g document.SourceObjName= 511.600.01.01.SAC.SOP 520.13 - Return Destruction of Samples.

I append the data and then display on datagrid but i want to sort the record on SourceobjName.

Can anyone help me?

jon.borchardt
February 26th, 2008, 03:54 PM
Create a hidden column and populate it with what you want to sort on.
Then sort on the hidden column.

technoroj
February 27th, 2008, 06:11 AM
do u know the concept of temp?

you want the sorted result .. right?

first populate it in one by achieving ur desire o/p , populate with your datagrid.