日期:2014-05-17  浏览次数:20739 次

要使用C#实现以下关于年月的循环
1. gridview里原有r行
2. rows[r].cells[0] = YYYYMM (如200802 带表年月,string格式)
3. 通过循环实现  rows【r+i】.cells【0】  从YYYYMM开始按照时间顺序出来

------解决方案--------------------
是要把0-r行按时间顺序再复制一份加到gridview里吗?

foreach(DataRow dr in dt.Select("",dt.Columns[0].ColumnName)) //按时间排序循环
{
   dt.LoadDataRow(dr.ItemArray,false);
}
------解决方案--------------------
嘿嘿:

public string GetNextRowYearAndMonth(int nRow)
{
    string strYearMonth = gv.Rows[nRow].Cells[0].Text;
    int nYearMonth = Convert.ToInt32(strYearMonth) + 1;
    if (nYearMonth % 100 == 13)
        nYearMonth += 88;  // 100 - 12 = 88
    return nYearMonth.ToString();
}