Monday, January 11, 2010

How to stop repeat in column value using datagrid C#?

How to stop repeat in column value using datagrid C#?
descr1 dsesc2 value
abc      xxxx    100
           yyyy     200
mno     xxxx    1000
                       5000
            yyyy      100 
I did following:
global variable:
       string acc5;
       string acc6;

  public void productsGridView_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
     {
        if ((e.Row.RowType == DataControlRowType.DataRow))
        {

 acc6 = e.Row.Cells[2].Text;
            if (e.Row.Cells[2].Text == acc5)
            {
                acc6 = e.Row.Cells[2].Text;
                e.Row.Cells[2].Text = "";
            }
            acc5 = acc6;
 }
    }

No comments: