This is my sorting function. How can I sort it numerically?
if (isPageIndexChanging)
{
dataView.Sort = string.Format("{0} {1}",
GridViewSortExpression, GridViewSortDirection);
}
else
{
dataView.Sort = string.Format("{0} {1}",
GridViewSortExpression, GetSortDirection());
}
"Cindy Lee" <ci******@hotmail.comwrote in message
news:eL**************@TK2MSFTNGP06.phx.gbl...
Oh, sorry. I do the sorting manually because it comes from an XML file.
But I still can't get the formatting to work. I guess I can fix it in the
XML file.
"Cindy Lee" <ci******@hotmail.comwrote in message
news:uc**************@TK2MSFTNGP02.phx.gbl...
I get my data from a basic xml file and make a datatable, and then bind
it
to the gridview. I think it's not sorting or dataformatString correctly
because it thinks it's a string and not a number. Is there a way to
tell
the gridview the value is a int?
This is how I bind the data:
DataSet aDataSet = new DataSet();
aDataSet.ReadXml(new StringReader(xmlString));
DataTable table = aDataSet.Tables[0];
GridView1.DataSource = table;
GridView1.AllowSorting = true;
GridView1.DataBind();
Here is a bound field:
<asp:BoundField DataField="percentage" HeaderText="%"
SortExpression="percentage" HtmlEncode="False"
DataFormatString="{0:P2}"
ReadOnly="True" />
All my value colums are sorted alphabetical