How to sort each row in a GridView based from a Field [RankOrder] from Database
-
I need your help but have ideas but do not know how to implement them. What I want is that the order of how the groups will eventually appear in the gridview are read from the database. I have 1 to x groups. In my GridView, the data are displayed with BoundField. It looks like this. <a href="http://img1.immage.de/0802377aunbenannt.jpg">http://img1.immage.de/0802377aunbenannt.jpg</a>[<a href="http://img1.immage.de/0802377aunbenannt.jpg" target="_blank" title="New Window">^</a>] My question is how can sort each row?
-
I need your help but have ideas but do not know how to implement them. What I want is that the order of how the groups will eventually appear in the gridview are read from the database. I have 1 to x groups. In my GridView, the data are displayed with BoundField. It looks like this. <a href="http://img1.immage.de/0802377aunbenannt.jpg">http://img1.immage.de/0802377aunbenannt.jpg</a>[<a href="http://img1.immage.de/0802377aunbenannt.jpg" target="_blank" title="New Window">^</a>] My question is how can sort each row?
Hi Muc! I am Not quite sure what are you looking for :laugh: but maybe you need to program the sort event of gridview... something like
protected void GV_MyData_Sorting(object sender, GridViewSortEventArgs e)
{
string sortExpression = e.SortExpression;
if (GridViewSortDirection == SortDirection.Ascending)
{
GridViewSortDirection = SortDirection.Descending;
SortGridView(sortExpression, DESCENDING);
}
else
{
GridViewSortDirection = SortDirection.Ascending;
SortGridView(sortExpression, ASCENDING);
}
}private void SortGridView(string sortExpression, string direction) { DataTable dt = GetDataTableSource()//Getting the data source of GV DataView dv = new DataView(dt); dv.Sort = sortExpression + direction; GV\_MyData.DataSource = dv; GV\_MyData.DataBind(); } private const string ASCENDING = " ASC"; private const string DESCENDING = " DESC"; public SortDirection GridViewSortDirection { get { if (ViewState\["sortDirection"\] == null) ViewState\["sortDirection"\] = SortDirection.Ascending; return (SortDirection)ViewState\["sortDirection"\]; } set { ViewState\["sortDirection"\] = value; } }
... it maybe helps a little! good luck! ;)
-
Hi Muc! I am Not quite sure what are you looking for :laugh: but maybe you need to program the sort event of gridview... something like
protected void GV_MyData_Sorting(object sender, GridViewSortEventArgs e)
{
string sortExpression = e.SortExpression;
if (GridViewSortDirection == SortDirection.Ascending)
{
GridViewSortDirection = SortDirection.Descending;
SortGridView(sortExpression, DESCENDING);
}
else
{
GridViewSortDirection = SortDirection.Ascending;
SortGridView(sortExpression, ASCENDING);
}
}private void SortGridView(string sortExpression, string direction) { DataTable dt = GetDataTableSource()//Getting the data source of GV DataView dv = new DataView(dt); dv.Sort = sortExpression + direction; GV\_MyData.DataSource = dv; GV\_MyData.DataBind(); } private const string ASCENDING = " ASC"; private const string DESCENDING = " DESC"; public SortDirection GridViewSortDirection { get { if (ViewState\["sortDirection"\] == null) ViewState\["sortDirection"\] = SortDirection.Ascending; return (SortDirection)ViewState\["sortDirection"\]; } set { ViewState\["sortDirection"\] = value; } }
... it maybe helps a little! good luck! ;)
Hi punkIsNotDead, what im askin myself is how i can sort my gridview depending on the rank column in the database? Its Loos like this http://img2.immage.de/09028ecclientpic.jpg[^] When one of the arrows is clicked on, for example Asceding then then the line should high slip. Let's say we click the down arrow for AEC, then its value must be recalculated, which would be called that previous rank_value [2] jumps to 1 And the value of 1 was is then 2 Once everything is to be bound to the GridView. http://img4.immage.de/09024bd3d3edbpic.jpg[^]
-
I need your help but have ideas but do not know how to implement them. What I want is that the order of how the groups will eventually appear in the gridview are read from the database. I have 1 to x groups. In my GridView, the data are displayed with BoundField. It looks like this. <a href="http://img1.immage.de/0802377aunbenannt.jpg">http://img1.immage.de/0802377aunbenannt.jpg</a>[<a href="http://img1.immage.de/0802377aunbenannt.jpg" target="_blank" title="New Window">^</a>] My question is how can sort each row?
Hi punkIsNotDead, what im askin myself is how i can sort my gridview depending on the rank column in the database? Its Loos like this <a href="http://img2.immage.de/09028ecclientpic.jpg">http://img2.immage.de/09028ecclientpic.jpg</a>[<a href="http://img2.immage.de/09028ecclientpic.jpg" target="_blank" title="New Window">^</a>] When one of the arrows is clicked on, for example Asceding then then the line should high slip. Let's say we click the down arrow for AEC, then its value must be recalculated, which would be called that previous rank_value [2] jumps to 1 And the value of 1 was is then 2 Once everything is to be bound to the GridView. <a href="http://img4.immage.de/09024bd3d3edbpic.jpg"></a> <a href="http://img4.immage.de/09024bd3d3edbpic.jpg">http://img4.immage.de/09024bd3d3edbpic.jpg</a>[<a href="http://img4.immage.de/09024bd3d3edbpic.jpg" target="_blank" title="New Window">^</a>]