0

Good day coders..

I just want to query how could i solve my problem regarding gridview, I want to compare the value of the current row to the previous row of the column, I dont know were should i start.

(ex. id, matnum,soldtoplan
      1,  101,  10101
      2,  102,  10102
      3,  102,  10102
      4,  103,  10103)

if this is my my result table based on my query. and was bind in gridview.
How could i compare the current row to previous row in the current column?

any idea? by the way i used grid_Rowdatabound and bind each column in it..

2
Contributors
1
Reply
14
Views
4 Years
Discussion Span
Last Post by LastMitch
0

any idea? by the way i used grid_Rowdatabound and bind each column in it..

Try this (not tested):

Protected Sub GridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView.RowCreated

If e.Row.RowType = DataControlRowType.DataRow Then

if (e.RowType != DataControlRowType.DataRow) return;  
if (e.Row.DataItemIndex ==0)  
{  
  e.Row.Cells[1].id = id.matnum;  
  return;  
}  
var thisRow = e.Row;   
var prevRow = GridView.Rows[e.Row.DataItemIndex-1];  
e.Row.Cells[1].id = (thisRow.Cells[1].Text == prevRow.Cells[1].Text) ? id.matnum : id.soldtoplan;  
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.